Package transientlibs.preui.agents.factories

Source Code of transientlibs.preui.agents.factories.BodyFactory

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.preui.agents.factories;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.World;
import transientlibs.bindedobjects.gamecontent.Terrain;
import transientlibs.processors.misc.Detonator;
import transientlibs.maps.units.GenericUnit;

/**
*
** @author kibertoad
*/
public class BodyFactory {

    public void materializeUnit(World world, GenericUnit unit) {


        BodyDef bodyDef = new BodyDef();
        bodyDef.type = BodyDef.BodyType.DynamicBody;
        bodyDef.position.set(unit.getMapCoords().x * Detonator.WORLD_TO_BOX2D * Terrain.tileWidth, unit.getMapCoords().y * Detonator.WORLD_TO_BOX2D * Terrain.tileHeight);
       
       

       
        unit.setBody (world.createBody(bodyDef));

        CircleShape circle = new CircleShape();
        circle.setRadius(64f * Detonator.WORLD_TO_BOX2D);

        FixtureDef fixtureDef = new FixtureDef();
        fixtureDef.shape = circle;
        fixtureDef.density = 0.2f;
        fixtureDef.friction = 0.4f;
        fixtureDef.restitution = 0.67f;

        Fixture fixture = unit.getBody().createFixture(fixtureDef);

       
        circle.dispose();       
    }
}
TOP

Related Classes of transientlibs.preui.agents.factories.BodyFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.