Search in sources :

Example 1 with FixtureDefBuilder

use of com.ilargia.games.entitas.egdx.base.util.FixtureDefBuilder in project Entitas-Java by Rubentxu.

the class AddViewSystem method execute.

@Override
public void execute(List<GameEntity> entities) {
    for (GameEntity e : entities) {
        Texture texture = assetsManager.getTexture(String.format("assets/textures/%1$s.png", e.getAsset().name));
        Body body = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(0.5f, 0.5f)).type(BodyDef.BodyType.KinematicBody).build();
        TextureRegion textureRegion = new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
        e.addTextureView(e.getAsset().name, textureRegion, body);
        //
        if (e.hasPosition()) {
            Position pos = e.getPosition();
            body.setTransform(new Vector2(pos.x, pos.y + 1), 0);
        }
    }
}
Also used : GameEntity(com.ilargia.games.logicbrick.gen.game.GameEntity) FixtureDefBuilder(com.ilargia.games.entitas.egdx.base.util.FixtureDefBuilder) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Position(com.ilargia.games.logicbrick.component.game.Position) Vector2(com.badlogic.gdx.math.Vector2) Texture(com.badlogic.gdx.graphics.Texture) Body(com.badlogic.gdx.physics.box2d.Body)

Aggregations

Texture (com.badlogic.gdx.graphics.Texture)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Body (com.badlogic.gdx.physics.box2d.Body)1 FixtureDefBuilder (com.ilargia.games.entitas.egdx.base.util.FixtureDefBuilder)1 Position (com.ilargia.games.logicbrick.component.game.Position)1 GameEntity (com.ilargia.games.logicbrick.gen.game.GameEntity)1