Jump to content

Using a Spritesheet as a texture atlas without a texture atlas data file


Recommended Posts

Long story short, i'm making particles that all are identical size/shape, but different colors. I have a .png image with every 32x32 frame is a different color particle. If I load this as a spritesheet with 

game.load.spritesheet('myparticles', 'media/myparticles.png',32,32);

is there a way to easily create the different color particles using the spritesheet here without going through the trouble of making a texture atlas data file? Like is there some way to turn all four of these frames into different display objects that i can feed into


to make it work elegantly and easily?



alternatively I'm willing to entertain different ways how you folks would do particles that share shape/size/function?

Link to comment
Share on other sites

When you are making particles, you can send an array of frames you want to make the particles from.

makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) 

side note: keys can also be an array of loaded images, and a random one will be chosen for each particle.

//This will give you one emitter with all frames used for particles, so you get a colourful particle explosion or stream...emitter.makeParticles("myparticles", [0,1,2,3]);//This is 4 emitters, each with a different frame, so you can have monochrome explosions...emitter_r.makeParticles("myparticles", [0]);emitter_g.makeParticles("myparticles", [1]);emitter_b.makeParticles("myparticles", [2]);emitter_o.makeParticles("myparticles", [3]);

For the group of 4 emitters, you would need to know what frame number each colour is to assign them to the right emitters...

Alternatively, you could extend the emitter class, give it a few different sprite pools, and when it comes time to shower particles everywhere, pass it a colour and pick sprites from the appropriate pool.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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