use of com.almasb.fxgl.dsl.components.ExpireCleanComponent in project FXGL by AlmasB.
the class RigidBodyPhysicsSample method spawnBullet.
private void spawnBullet(double x, double y, double vx, double vy) {
var physics = new PhysicsComponent();
physics.setFixtureDef(new FixtureDef().density(25.5f).restitution(0.5f));
physics.setBodyType(BodyType.DYNAMIC);
physics.setOnPhysicsInitialized(() -> {
physics.setLinearVelocity(vx * 10, vy * 10);
});
entityBuilder().at(x, y).bbox(new HitBox(BoundingShape.circle(450 / 15.0 / 2.0))).view(texture("ball.png", 450 / 15.0, 449 / 15.0)).with(physics).with(new ExpireCleanComponent(Duration.seconds(5)).animateOpacity()).buildAndAttach();
}
use of com.almasb.fxgl.dsl.components.ExpireCleanComponent in project FXGL by AlmasB.
the class RopeJointSample method spawnBullet.
private void spawnBullet(double x, double y, double vx, double vy) {
var physics = new PhysicsComponent();
physics.setFixtureDef(new FixtureDef().density(25.5f).restitution(0.5f));
physics.setBodyType(BodyType.DYNAMIC);
physics.setOnPhysicsInitialized(() -> {
physics.setLinearVelocity(vx * 10, vy * 10);
});
entityBuilder().at(x, y).bbox(new HitBox(BoundingShape.circle(450 / 15.0 / 2.0))).view(texture("ball.png", 450 / 15.0, 449 / 15.0)).with(physics).with(new ExpireCleanComponent(Duration.seconds(5)).animateOpacity()).buildAndAttach();
}
use of com.almasb.fxgl.dsl.components.ExpireCleanComponent in project FXGL by AlmasB.
the class FiringRangeFactory method newTarget.
@Spawns("target")
public Entity newTarget(SpawnData data) {
var box = new Box(5, 5, 0.2);
box.setMaterial(new PhongMaterial(Color.DARKKHAKI));
var e = entityBuilder(data).type(FiringRangeEntityType.TARGET).bbox(new HitBox(BoundingShape.box3D(5, 5, 0.2))).view(box).collidable().with(new Projectile3DComponent(new Point3D(1, 0, 0), 15)).with(new ExpireCleanComponent(Duration.seconds(6))).build();
animationBuilder().duration(Duration.seconds(0.6)).interpolator(Interpolators.ELASTIC.EASE_OUT()).scale(e).from(new Point3D(0, 0, 0)).to(new Point3D(1, 1, 1)).buildAndPlay();
return e;
}
Aggregations