0
\$\begingroup\$

I want to use frames from a spritesheet as particles for my emitter.

I load my spritesheet with :

game.load.spritesheet('particles_sheet', 'http://stuff.lck.io/luckyslot/sprite_sheet.png', 50, 50, 6);

var emitter = game.add.emitter(game.world.centerX, canvas_height, 80);

And i need some code to load the right frame at random :

emitter.makeParticles('particles_sheet');

Any idea?

\$\endgroup\$
1
\$\begingroup\$

I used this code to generate a simple array with consecutive values like [0,1,2,3,4,5] starting at 0

var particules = 6;
var _pArray = Array.apply(null, {length: particules}).map(Number.call, Number)

and then i used this array as a second param in the makeParticles method :

emitter.makeParticles('logo_sheet', _pArray );

Works perfectly !

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.