use of com.almasb.fxgl.entity.control.ProjectileControl in project FXGL by AlmasB.
the class PlayerControl method shoot.
public void shoot(Point2D direction) {
Entity bullet = new Entity();
bullet.getTypeComponent().setValue(FXShooterApp.EntityType.BULLET);
bullet.getPositionComponent().setValue(getEntity().getComponent(PositionComponent.class).getValue().add(20, 20));
bullet.getViewComponent().setView(new EntityView(new Rectangle(10, 2, Color.BLACK)), true);
bullet.addComponent(new CollidableComponent(true));
bullet.addControl(new OffscreenCleanControl());
bullet.addControl(new ProjectileControl(direction, 10 * 60));
BulletComponent bulletData = new BulletComponent();
bulletData.setDamage(1);
bulletData.setHp(1);
bulletData.setSpeed(10);
bullet.addComponent(bulletData);
getEntity().getWorld().addEntity(bullet);
}
Aggregations