Has anyone managed to develop fireworks? This is the closest I can get::
Wondering if there’s a better method out there.
Has anyone managed to develop fireworks? This is the closest I can get::
Wondering if there’s a better method out there.
I don’t know how to share examples like others have in the past. Here is the code.
var config = {
type: Phaser.WEBGL,
width: 800,
height: 600,
backgroundColor: '#000',
parent: 'phaser-example',
scene: {
preload: preload,
create: create
}
};
var game = new Phaser.Game(config);
function preload ()
{
this.load.atlas('flares', 'assets/particles/flares.png', 'assets/particles/flares.json');
}
function create ()
{
var particles = this.add.particles('flares');
for (let i = 0; i < 10; i++)
{
let x = Phaser.Math.Between(400, 300);
let y = Phaser.Math.Between(400, 300);
var emitter = particles.createEmitter({
frame: [ 'red', 'blue', 'green', 'yellow' ],
x: x,
y: y,
speed: 40,
lifespan: 1000,
maxParticles: 40,
scale: { min: 0, max: .07 },
alpha: { start: 0, end: 1 },
quantity: 3,
blendMode: 'ADD',
delay: Math.random() * 2000
});
}
}
Improved I think (full page):
Render texture:
Thank you so much, it helps a lot
Actually, there should not be empty space created at the center of the particles.
I added some particle processors that slow the flares down after the explosion. Looks a bit more like real fireworks.
I added some drag and flicker.