Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

particle texture


enriqueto
 Share

Recommended Posts

Yes!. When calling Phaser.Emitter#makeParticles you can pass a texture atlas key as the first parameter and as the second pass the frame number or name.

//emitter with single loaded imageemitter.makeParticles('imageID')//emitter with single image from an atlasemitter.makeParticles('atlasID', 'frameName')//or multiple frame from an atlasemitter.makeParticles(      ['atlasID'],      [ 'particle_1',        'particle_2',        'particle_3,        'particle_4,        'particle_5'])

The emitter will randomly select one of the given sprites to create a particle.

Link to comment
Share on other sites

Yes you are right. I just noticed this myself.  Although I changed the definitions to "any" on my local copy, I am not having any luck with that:

Although I am using 1.2

Uncaught TypeError: Cannot read property 'checkCollision' of null

 

I thought I would pass in just string references to makeParticles:

makeParticles( AssetList.ATLAS_UI, AssetList.STAR_PARTICLE, 10);

But I also tried arrays

makeParticles( [AssetList.Atlas_UI], [AssetList.STAR_PARTICLE], 10);

Both get the same error.  It appears the body of the created particle has not been set?

Link to comment
Share on other sites

@clark: You're right, the emitter is broken in 2.x as it's not ported to the new p2 engine yet. But RavalMatic is talking about 1.x. The emitter is still working there he's only talking about the signature.

 

But you can do a dirty fix. See the diff file here:


 

@RavalMatic: You're wrong. The signature is kind of polymorphic, you can pass an array or a string. I use it in both ways. It looks like you're posting the Typescript signature. Look in the JS source, there you see that the parameters are array or string. Or look at the code itself.

 



* @param {array|string} keys - A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random.
* @param {array|number} frames - A frame number, or array of frames that the sprite will use. If an array one is picked at random.

//from Phaser.Particles.Arcade.Emitter#makeParticles
if (typeof keys === 'object')
{
rndKey = this.game.rnd.pick(keys);
}

if (typeof frames === 'object')
{
rndFrame = this.game.rnd.pick(frames);
}



cheers

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...