enriqueto Posted February 20, 2014 Share Posted February 20, 2014 Is it possible to use a texture from a texture atlas for an emmiter? Link to comment Share on other sites More sharing options...
george Posted February 20, 2014 Share Posted February 20, 2014 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 More sharing options...
enriqueto Posted February 21, 2014 Author Share Posted February 21, 2014 not really the signature of makeParticles on v1.1.5 is: makeParticles(keys: string[], frames: number[], quantity: number, collide?: boolean, collideWorldBounds?: boolean): Phaser.Particles.Arcade.Emitter; Link to comment Share on other sites More sharing options...
clark Posted February 23, 2014 Share Posted February 23, 2014 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.2Uncaught 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 arraysmakeParticles( [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 More sharing options...
george Posted February 25, 2014 Share Posted February 25, 2014 @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:https://gist.github.com/georgiee/9210520 @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 More sharing options...
Recommended Posts