use of com.almasb.fxgl.physics.PhysicsParticleComponent in project FXGL by AlmasB.
the class PhysicsParticlesSample method initCloth.
private void initCloth() {
// 1. define how particles should behave
ParticleGroupDef groupDef = new ParticleGroupDef();
groupDef.setTypes(EnumSet.of(ParticleType.ELASTIC));
// 2. create component and set data
PhysicsParticleComponent ppComponent = new PhysicsParticleComponent();
ppComponent.setDefinition(groupDef);
ppComponent.setColor(Color.DARKGREEN.brighter());
// 3. create entity, place it and specify volume of particles via bounding box
Entity cloth = new Entity();
cloth.getPositionComponent().setValue(150, 10);
cloth.getBoundingBoxComponent().addHitBox(new HitBox("MAIN", BoundingShape.box(75, 150)));
// 4. add component
cloth.addComponent(ppComponent);
getGameWorld().addEntity(cloth);
}
use of com.almasb.fxgl.physics.PhysicsParticleComponent in project FXGL by AlmasB.
the class PhysicsParticlesSample method initLiquid.
private void initLiquid() {
ParticleGroupDef groupDef = new ParticleGroupDef();
groupDef.setTypes(EnumSet.of(ParticleType.VISCOUS, ParticleType.TENSILE));
PhysicsParticleComponent ppComponent = new PhysicsParticleComponent();
ppComponent.setDefinition(groupDef);
ppComponent.setColor(Color.BLUE.brighter());
Entity liquid = new Entity();
liquid.getPositionComponent().setValue(300, 10);
liquid.getBoundingBoxComponent().addHitBox(new HitBox("MAIN", BoundingShape.circle(35)));
liquid.addComponent(ppComponent);
getGameWorld().addEntities(liquid);
}
use of com.almasb.fxgl.physics.PhysicsParticleComponent in project FXGL by AlmasB.
the class ScifiSample method initLiquid.
private void initLiquid() {
ParticleGroupDef groupDef = new ParticleGroupDef();
groupDef.setTypes(EnumSet.of(ParticleType.WATER));
PhysicsParticleComponent ppComponent = new PhysicsParticleComponent();
ppComponent.setDefinition(groupDef);
ppComponent.setColor(Color.BLUE.brighter());
Entity liquid = new Entity();
liquid.setPosition(playerControl.getEntity().getComponent(PositionComponent.class).getValue().subtract(0, 650));
liquid.getBoundingBoxComponent().addHitBox(new HitBox("MAIN", BoundingShape.circle(55)));
liquid.addComponent(ppComponent);
getGameWorld().addEntities(liquid);
}
Aggregations