use of com.almasb.fxgl.particle.ParticleEmitter in project FXGL by AlmasB.
the class ParticlesSample method initInput.
@Override
protected void initInput() {
onBtnDown(MouseButton.PRIMARY, () -> {
// 1. create and configure emitter + component
ParticleEmitter emitter = ParticleEmitters.newFireEmitter();
emitter.setBlendMode(BlendMode.SRC_OVER);
emitter.setMaxEmissions(100);
ParticleComponent component = new ParticleComponent(emitter);
// 2. add component to entity
entityBuilder().at(getInput().getMousePositionWorld()).with(component).buildAndAttach();
});
onBtnDown(MouseButton.SECONDARY, () -> {
// 1. create and configure emitter + component
ParticleEmitter emitter = ParticleEmitters.newExplosionEmitter(400);
emitter.setSourceImage(image("brick.png"));
ParticleComponent component = new ParticleComponent(emitter);
// 2. add component to entity
entityBuilder().at(getInput().getMousePositionWorld()).with(component).buildAndAttach();
});
}
use of com.almasb.fxgl.particle.ParticleEmitter in project FXGL by AlmasB.
the class RainSample method initGame.
@Override
protected void initGame() {
entityBuilder().view(texture("underwater3.png", getAppWidth(), getAppHeight())).buildAndAttach();
// example - multiply color with existing
ParticleEmitter emitter = ParticleEmitters.newRainEmitter(getAppWidth() / 2);
emitter.setSourceImage(texture("rain.png").multiplyColor(Color.BLUE));
entityBuilder().with(new ParticleComponent(emitter)).buildAndAttach();
// example - set color
ParticleEmitter emitter2 = ParticleEmitters.newRainEmitter(getAppWidth() / 2);
emitter2.setSourceImage(texture("rain.png").toColor(Color.YELLOW));
emitter2.setInterpolator(Interpolators.EXPONENTIAL.EASE_OUT());
entityBuilder().at(getAppWidth() / 2, 0).with(new ParticleComponent(emitter2)).buildAndAttach();
}
use of com.almasb.fxgl.particle.ParticleEmitter in project FXGL by AlmasB.
the class ParticleScaleSample method initGame.
@Override
protected void initGame() {
ParticleEmitter emitter = ParticleEmitters.newFireEmitter();
emitter.setSpawnPointFunction(i -> new Point2D(0, 0));
emitter.setSourceImage(texture("brick.png"));
emitter.setBlendMode(BlendMode.SRC_OVER);
emitter.setSize(12, 14);
emitter.setScaleFunction(i -> new Point2D(0, 0));
emitter.setEntityScaleFunction(() -> new Point2D(1.75, 1.75));
emitter.setScaleOriginFunction(i -> new Point2D(12, 32));
var e = entityBuilder().at(250, 250).viewWithBBox("brick.png").scale(1.75, 1.75).with(new ParticleComponent(emitter)).buildAndAttach();
e.getTransformComponent().setScaleOrigin(new Point2D(12, 32));
}
Aggregations