use of com.ilargia.games.logicbrick.component.game.Position in project Entitas-Java by Rubentxu.
the class EntityIndexExtension method addEntityIndices.
public static void addEntityIndices(Entitas contexts) {
EntityIndex<GameEntity, Integer> positionIndex = new EntityIndex(contexts.game.getGroup(GameMatcher.Position()), (e, c) -> {
Position positionComponent = (Position) c;
return positionComponent != null ? (positionComponent.x << shiftX) + positionComponent.y : (((GameEntity) e).getPosition().x << shiftX) + ((GameEntity) e).getPosition().y;
});
contexts.game.addEntityIndex(PositionKey, positionIndex);
}
use of com.ilargia.games.logicbrick.component.game.Position in project Entitas-Java by Rubentxu.
the class AnimatePositionSystem method execute.
@Override
public void execute(List<GameEntity> entities) {
for (GameEntity e : entities) {
Position pos = e.getPosition();
//e.getTextureView().body.setTransform(new Vector2(0, -12), new Vector2(pos.x, pos.y - 1), true);
moveFocused(new Vector2(pos.x, pos.y - 1), e.getTextureView().body);
}
}
use of com.ilargia.games.logicbrick.component.game.Position in project Entitas-Java by Rubentxu.
the class GameEntity method addPosition.
public GameEntity addPosition(int x, int y) {
Position component = (Position) recoverComponent(GameComponentsLookup.Position);
if (component == null) {
component = new Position(x, y);
} else {
component.x = x;
;
component.y = y;
}
addComponent(GameComponentsLookup.Position, component);
return this;
}
use of com.ilargia.games.logicbrick.component.game.Position 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);
}
}
}
use of com.ilargia.games.logicbrick.component.game.Position in project Entitas-Java by Rubentxu.
the class GameEntity method replacePosition.
public GameEntity replacePosition(int x, int y) {
Position component = (Position) recoverComponent(GameComponentsLookup.Position);
if (component == null) {
component = new Position(x, y);
} else {
component.x = x;
;
component.y = y;
}
replaceComponent(GameComponentsLookup.Position, component);
return this;
}
Aggregations