本文整理汇总了Java中com.badlogic.ashley.core.Entity.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.remove方法的具体用法?Java Entity.remove怎么用?Java Entity.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.ashley.core.Entity
的用法示例。
在下文中一共展示了Entity.remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: placeTowers
import com.badlogic.ashley.core.Entity; //导入方法依赖的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: update
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
@Override
public void update(Entity e, float deltaTime, Level level) {
if (done) return;
PositionComponent pos = PositionComponent.MAPPER.get(e);
VelocityComponent vel = VelocityComponent.MAPPER.get(e);
if (vel == null) {
vel = new VelocityComponent();
e.add(vel);
}
ShipComponent ship = ShipComponent.MAPPER.get(e);
if (speed < 0) speed = ship.moveSpeed;
double dx = x - pos.getX();
double dy = y - pos.getY();
double dist = Math.hypot(dx, dy);
if (dist < speed * deltaTime) {
done = true;
pos.setX((float) x);
pos.setY((float) y);
e.remove(VelocityComponent.class);
} else {
vel.vx = (float) (speed * dx / dist);
vel.vy = (float) (speed * dy / dist);
}
}
示例3: update
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
@Override
public void update(Entity e, float deltaTime, Level level) {
if (done) {
return;
}
PositionComponent pos = PositionComponent.MAPPER.get(e);
VelocityComponent vel = VelocityComponent.MAPPER.get(e);
if (vel == null) {
vel = new VelocityComponent();
e.add(vel);
}
double dx = x - pos.getX();
double dy = y - pos.getY();
if (time < 0) {
done = true;
pos.setX((float) x);
pos.setY((float) y);
e.remove(VelocityComponent.class);
} else {
vel.vx = (float) (dx / time);
vel.vy = (float) (dy / time);
time -= deltaTime;
}
}
示例4: receiveObstacle
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
private void receiveObstacle(ByteBuffer buffer) {
Entity entity = entityFactory.createObstacle();
entity.remove(NetworkAddComponent.class);
TransformComponent transform = transformMapper.get(entity);
MovementComponent movement = movementMapper.get(entity);
transform.position.x = buffer.getFloat();
transform.position.y = buffer.getFloat();
movement.velocity.x = buffer.getFloat();
movement.velocity.y = buffer.getFloat();
getEngine().addEntity(entity);
}
示例5: receiveBullet
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
private void receiveBullet(String playerId, ByteBuffer buffer) {
// Gdx.app.debug(TAG, "receiveBullet: ");
Entity entity = entityFactory.createBullet(playerId);
entity.remove(NetworkAddComponent.class);
TransformComponent transform = transformMapper.get(entity);
MovementComponent movement = movementMapper.get(entity);
transform.position.x = buffer.getFloat();
transform.position.y = buffer.getFloat();
movement.velocity.x = buffer.getFloat();
movement.velocity.y = buffer.getFloat();
getEngine().addEntity(entity);
}
示例6: onEntityDestroyed
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
@Override
public void onEntityDestroyed(Engine engine, Entity entity, Entity source) {
AnimationComponent animation = new AnimationComponent();
// TODO: 31-Mar-17 Figure out why this line sometime causes a null reference
animation.removeEntityAfterAnimation = true;
animation.frames.addAll(ServiceLocator.getAppComponent().getAnimationFactory().getMediumExplosion());
entity.add(animation);
world.audioService.playSound(AssetService.SoundAsset.SOUND_EXPLOSION_WAV);
entity.remove(CollisionComponent.class);
entity.remove(MovementComponent.class);
}
示例7: update
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
@Override
public void update(Entity e, float deltaTime, Level level) {
if (done) return;
RotationComponent rot = RotationComponent.MAPPER.get(e);
RotationVelocityComponent vel = RotationVelocityComponent.MAPPER.get(e);
if (vel == null) {
vel = new RotationVelocityComponent();
e.add(vel);
}
float dr = (float) (r - rot.r);
//Fix the angle
while (dr < -180) {
dr += 360;
}
//Fix the angle
while (dr > 180) {
dr -= 360;
}
if (Math.abs(dr) < rotateSpeed * deltaTime) {
done = true;
rot.r = (float) r;
e.remove(RotationVelocityComponent.class);
} else {
vel.vr = (float) (Math.signum(dr) * rotateSpeed);
}
}
示例8: processEntity
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
private void processEntity(Entity entity, float deltaTime) {
OrderComponent order = OrderComponent.MAPPER.get(entity);
if (order.size() == 0) {
entity.remove(OrderComponent.class);
return;
}
order.initAll(entity, level, this);
while (order.size() > 0 && !order.peek().isValidFor(entity)) {
order.pop();
}
if (order.size() == 0) {
entity.remove(OrderComponent.class);
return;
}
order.peek().update(entity, deltaTime, level);
if (order.peek().completed(entity)) {
order.pop();
}
if (order.size() == 0) {
entity.remove(OrderComponent.class);
}
}
示例9: removeEffect
import com.badlogic.ashley.core.Entity; //导入方法依赖的package包/类
@Override
protected void removeEffect(PooledEngine engine, Entity entity, EffectComponent effectComponent) {
Gdx.app.debug(TAG, "removeEffect: ");
entity.remove(DamageComponent.class);
healthComponent.ignoredEntities = oldHealthIgnore;
}