Jump to content

Many atlas for one sprite


ohenley
 Share

Recommended Posts

Hi to all,

I have many animations for a ninja sprite (eg idle, run, punch etc). Using Texture Packer, the atlas creation generates 2 *.png and  2 *.json.
Using the best placement possible Texture Packer splits some animations between two textures (eg. the run animation has frames in both PNGs).

How do I reassemble those frames in Phaser for my eg run anim? Is it possible?

Here is what I would like to do... but this does not work:

this.game.load.atlas('ninja', 'assets/ninja-1.png', 'assets/ninja-1.json');
this.game.load.atlas('ninja', 'assets/ninja-2.png', 'assets/ninja-2.json');

this.ninja = game.add.sprite(x, y, 'ninja');
this.ninja.animations.add('run', Phaser.Animation.generateFrameNames('run', 0, 14, '', 2), 30, true); // frame 0,1,2,5,14 are referenced in ninja-1.json and found in ninja-1.png. frame 3,4,6,7,8,9,10,11,12,13 are referenced in ninja-2.json and found in ninja-2.png

Note: All this works in Texture Packer; it knows, for an animation, where to get the frames from both PNGs.
Note2: It also raises the question of how to bind many atlases to a single sprite even if no frames, for a given animation, are split between textures.

Thank you,

ohenley

Link to comment
Share on other sites

Hi, it is not currently possible, but (if I am not wrong) I think something like this will be available in future...

On the other side: if you have lot of animations, consider using some sort of skeletal animation. It is big texture space saver (for some CPU during runtime). I am using Spriter (https://brashmonkey.com/) for this and playing it with Spriter Player for Phaser (https://github.com/SBCGames/Spriter-Player-for-Phaser)

Link to comment
Share on other sites

Ok super. At least I know what is possible and what is not. I'll cut down on the frame rate of my anims and will make them fit in a 4096x4096 texture.

1. Do you know if 'most' low end/embedded graphic cards accept a max 4096x4096 texture size? I would think so... I'll do a quick search for common graphic card chipset to see if I am landing into a safe zone.

Thank you,

ohenley

Link to comment
Share on other sites

On 2. 11. 2016 at 3:07 PM, ohenley said:

Do you know if 'most' low end/embedded graphic cards accept a max 4096x4096 texture size? I would think so... I'll do a quick search for common graphic card chipset to see if I am landing into a safe zone.

2048x2048 is still safe size for current devices. With 4096x4096 you may encounter problems.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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