Jump to content

Extract animation from frame within TextureAtlas


eguneys
 Share

Recommended Posts

If I have a spritesheet, i could extract the animations with Phaser.Loader

spritesheet(key, url, frameWidth, frameHeight, frameMaxmarginspacing)

I have a spritesheet inside a texture atlas. So whole spritesheet is considered a single frame.

 

So far, i had to manually edit the json file to extract each animation frame.

 

If i have this spritesheet frame:

 

"player": { x: 0, y: 0, w: 100, h: 10 }

 

and if frameWidth is 10, i end up doing this manually:

 

"player1": { x: 0, y: 0, w: 10, h:10 },

"player2": { x: 10, y: 0, w: 10, h:10},

...

 

I want to keep the spritesheet inside the texture atlas, and extract the animation frames automatically. Is there an easy way to do this?

Link to comment
Share on other sites

Split the spritesheet up into individual frames and then put those into the texture atlas - then you'll have all of your frames separated for you with all of the extra space-saving benefits of using a texture atlas. Once this is done, so long as you've numbered your frames appropriately you can use Phaser.Animation.generateFrameNames to create your array of frame names to pass into the animation.

 

Spritesheets and texture atlases are two completely separate ways of arranging assets, with atlases generally being the superior method, due to increased efficiency. Putting spritesheets whole into atlases doesn't make sense.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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