本文整理汇总了Java中com.badlogic.ashley.utils.ImmutableArray.first方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableArray.first方法的具体用法?Java ImmutableArray.first怎么用?Java ImmutableArray.first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.ashley.utils.ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.first方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: placeTowers
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
private void placeTowers(int button) {
if (_isPlacementMode) {
Tile tile = getTileAtMouse();
ImmutableArray<Entity> towerEntitys = getAshleyEngine().getEntitiesFor(_towerFamily);
Entity first = towerEntitys.first();
first.remove(MouseImageComponent.class);
first.getComponent(PositionComponent.class).position.x = tile.getCords().x;
first.getComponent(PositionComponent.class).position.y = tile.getCords().y;
first.add(new OffsetComponent(16, 16));
tile.setType(TileType.WALL);
tile.setEntity(first);
getAshleyEngine().getSystem(TowerPlacementSystem.class).tintTile(null);
InputHandler.setPlacementMode(false);
_ef.getPlayer().getComponent(MoneyComponent.class).money -= first.getComponent(TowerStatComponent.class)._buyCost;
}
}
示例2: closestEntity
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
public static Entity closestEntity(Vector3 position, ImmutableArray<Entity> entities) {
if (entities == null || entities.size() == 0)
return null;
Entity targetEntity = entities.first();
float targetDist = MyMath.distance(position, Mappers.transform.get(targetEntity).pos);
for (Entity searchEnt : entities) {
float dist = MyMath.distance(Mappers.transform.get(searchEnt).pos, position);
if (dist < targetDist) {
targetDist = dist;
targetEntity = searchEnt;
}
}
return targetEntity;
}
示例3: isRightButtonClicked
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
private boolean isRightButtonClicked(int button) {
if (_isPlacementMode) {
if (button == Input.Buttons.RIGHT) {
ImmutableArray<Entity> towerEntitys = getAshleyEngine().getEntitiesFor(_towerFamily);
Entity first = towerEntitys.first();
getAshleyEngine().removeEntity(first);
InputHandler.setPlacementMode(false);
getAshleyEngine().getSystem(TowerPlacementSystem.class).tintTile(null);
return true;
}
}
return false;
}
示例4: mouseMoved
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
@Override
public boolean mouseMoved(int screenX, int screenY) {
if (_isPlacementMode) {
mouseOverTintTiles();
ImmutableArray<Entity> towerEntitys = getAshleyEngine().getEntitiesFor(_towerFamily);
Entity first = towerEntitys.first();
Vector3 mousePos = _gameCamera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
PositionComponent component = first.getComponent(PositionComponent.class);
component.position.x = mousePos.x;
component.position.y = mousePos.y;
}
return false;
}
示例5: getPointerPosition
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
private PointerPositionComponent getPointerPosition() {
ImmutableArray<Entity> entities = gameLoop.getEntitiesFor(Family
.all(PointerPositionComponent.class).get());
Entity entity = null;
if (entities.size() == 0) {
entity = new Entity();
gameLoop.addEntity(entity);
} else {
entity = entities.first();
}
return gameLoop.addAndGetComponent(entity,
PointerPositionComponent.class);
}