use of com.almasb.fxgl.effect.ParticleControl in project FXGL by AlmasB.
the class ScifiSample method addRain.
private void addRain() {
ParticleEmitter emitter = ParticleEmitters.newRainEmitter(getWidth());
emitter.setSourceImage(getAssetLoader().loadTexture("rain.png").multiplyColor(Color.LIGHTBLUE).getImage());
Entity rain = Entities.builder().with(new ParticleControl(emitter)).buildAndAttach(getGameWorld());
rain.getPositionComponent().xProperty().bind(getGameScene().getViewport().xProperty());
rain.getPositionComponent().yProperty().bind(getGameScene().getViewport().yProperty());
}
use of com.almasb.fxgl.effect.ParticleControl in project FXGL by AlmasB.
the class GameScene method onUpdate.
public void onUpdate(double tpf) {
getViewport().onUpdate(tpf);
boolean dirty = drawables.isNotEmpty() || particles.isNotEmpty();
if (dirty || wasDirty) {
particlesGC.setGlobalAlpha(1);
particlesGC.setGlobalBlendMode(BlendMode.SRC_OVER);
// https://github.com/AlmasB/FXGL/issues/494
particlesGC.clearRect(0, 0, getWidth(), getHeight());
wasDirty = false;
}
for (Entity e : drawables) {
e.getComponentOptional(DrawableComponent.class).ifPresent(d -> d.draw(particlesGC));
}
for (ParticleControl particle : particles) {
particle.renderParticles(particlesGC, getViewport().getOrigin());
}
wasDirty = dirty;
}
Aggregations