Reputation: 223
I am trying to make a snow effect behind the main menu of my game using the particle emitter but particles spawn way too fast.
I have this code:
var particles = this.add.particles('snow');
var emitter = particles.createEmitter({
speedY: { min: 15, max: 40 },
gravityY: 0,
scale: 0.2,
quantity: 1,
lifespan: { min: 28000, max: 30000 },
emitZone: { source: new Phaser.Geom.Line(-20, -100, 820, -100 )}
});
And quantity is only one, so I do not know how to fix this. Is it possible to change the spawn speed of the particles?
I am using Phaser 3 and the arcade physics.
Upvotes: 3
Views: 1307
Reputation: 4323
I achieved for my snow effect this way, maybe it helps you. It has a random wind blow and rotation for the snowflakes.
this.emitter = snowParticles.createEmitter({
frame: [0, 1, 2, 3, 4, 5],
x: {min: 0, max: this.sys.game.canvas.width},
y: 0 ,
lifespan: {min: 20000, max: 60000},
speedY: 50,
gravityX: Math.ceil((Math.random() - 0.5) * 2) < 1 ? -10 : 10,
gravityY: 10,
minVelocityY: 10,
maxVelocityY: 30,
minVelocityX: 10,
maxVelocityX: 30,
quantity: 1,
scale: 0.4,
frequency: 1000,
blendMode: 'ADD',
rotate: { start: 0, end: 180 }
});
Here is the uploaded live example: https://vajda.co.uk/demo/react/winter-landscape/
Upvotes: 0
Reputation: 1122
I think what you're looking for is the frequency setting.
It doesn't exactly change the spawn speed, but it changes the time between flow cycles. If you add a frequency: 1000
to the emitter you currently have, it gives you about 8-10 particles on the screen at a time. You can play with that number until you get the flow you want.
Upvotes: 5