当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableArray.first方法代码示例

本文整理汇总了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;
	}
}
 
开发者ID:JoakimRW,项目名称:ExamensArbeteTD,代码行数:17,代码来源:InputHandler.java

示例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;
}
 
开发者ID:0XDE57,项目名称:SpaceProject,代码行数:17,代码来源:Misc.java

示例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;
	}
 
开发者ID:JoakimRW,项目名称:ExamensArbeteTD,代码行数:16,代码来源:InputHandler.java

示例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;
}
 
开发者ID:JoakimRW,项目名称:ExamensArbeteTD,代码行数:16,代码来源:InputHandler.java

示例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);
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:14,代码来源:DefaultGameView.java


注:本文中的com.badlogic.ashley.utils.ImmutableArray.first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。