use of com.almasb.fxgl.entity.Entity in project FXGL by AlmasB.
the class ViewportTest method initGame.
@Override
protected void initGame() {
Entity entity = Entities.builder().at(100, 100).viewFromNodeWithBBox(new Rectangle(40, 40)).buildAndAttach(getGameWorld());
playerPosition = entity.getPositionComponent();
bbox = entity.getBoundingBoxComponent();
}
use of com.almasb.fxgl.entity.Entity in project FXGL by AlmasB.
the class BoundingBoxComponentTest method setUp.
@BeforeEach
public void setUp() throws Exception {
Entity entity = new Entity();
position = entity.getPositionComponent();
bbox = entity.getBoundingBoxComponent();
}
use of com.almasb.fxgl.entity.Entity in project FXGL by AlmasB.
the class ParticlesSample method initInput.
@Override
protected void initInput() {
Input input = getInput();
input.addAction(new UserAction("Spawn Explosion") {
@Override
protected void onActionBegin() {
// 1. create entity
Entity explosion = new Entity();
explosion.setPosition(input.getMousePositionWorld());
// 2. create and configure emitter + control
ParticleEmitter emitter = ParticleEmitters.newExplosionEmitter(400);
ParticleControl control = new ParticleControl(emitter);
// we also want the entity to destroy itself when particle control is done
control.setOnFinished(explosion::removeFromWorld);
// 3. add control to entity
explosion.addControl(control);
// 4. add entity to game world
getGameWorld().addEntity(explosion);
}
}, MouseButton.PRIMARY);
}
use of com.almasb.fxgl.entity.Entity in project FXGL by AlmasB.
the class PhysicsParticlesSample method initGround.
private void initGround() {
Entity ground = new Entity();
ground.getPositionComponent().setValue(100, 500);
ground.getViewComponent().setView(new EntityView(new Rectangle(800, 100)), true);
ground.addComponent(new PhysicsComponent());
getGameWorld().addEntity(ground);
}
use of com.almasb.fxgl.entity.Entity 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);
}
Aggregations