Jump to content

Choosing the Correct Framework in Texture Packer


Recommended Posts

I have a few questions about using Texture Packer for Phaser projects, if anyone has the time, the knowledge and the inclination to answer.  There isn't much information available in tutorial form or documentation that I have found.  There are in fact tutorials referenced by Texture Packer itself, but they don't cover everything I want to know.


I own the full version of Texture Packer.  I use Phaser.  I've been selecting JSON (Array) for my spritesheets, but there is also a JSON (Hash).  Today I just noticed that there are two more: Phaser (JSONArray) and Phaser (JSONHash).


I'm curious about three things:

1. Is there an advantage or necessity in using any of these over the other for a spritesheet?

2. Is there an advantage or necessity in using any of these for a texture atlas?

3. Are there any gotchas in using a texture atlas? I've seen a few posts about poor performance...


I guess I also would like to ask if there are different loading API for each of these.  I'm pretty sure I saw a specific API for Hashes, but would it apply to both JSON (Hash) and Phaser (JSONHash)?


Thank you for your time, even if you simply just read this and were unable to help.

Link to comment
Share on other sites



 ad 1] As I understand it: in spritesheets you have fixed size frames (let's say 64x64 for all frames) and you can end up with lot of wasted space, but you do not need additional metadata (where in the bitmap is sprite located and what is its dimension). Problems come when you want to place for example 2 characters with different frame size into one texture. This can be done with atlases. When atlases are created there is usually some kind of rectangle bin packing optimization and as an output you get final image + metadata. Empty space is trimmed and also this information is stored in metadata to calculate correct position during game (not by you, but by Phaser). So, I think, that for spritesheet with fixed frame size you do not need any additional metadata (array or hash or whatever...),


 ad 2] Yes, it is necessary to use any of them for atlases as every time you create atlas, frames can be on different position (based on result of optimization). The file says where is frame located and how big it is (+ additional information),


 ad 3] Atlas, as well as spritesheet should definitely improve performace ... for WebGL this is 100% sure (you avoid texture swaping and thus changing inner OpenGL states. Changing these states would force OpenGL to flush after every texture change and do some additional internal initialization)


For APIs look at this question: http://www.html5gamedevs.com/topic/11765-unable-to-display-a-specific-atlas-frame/  igin wrote there nice summary. It does not matter whether you use Hash or Array. Both will do the job. I am not using Texture Packer, but my own tool that has some advantages for me and I added possibility to export into JSON Array. And it works great...

Link to comment
Share on other sites


  • Recently Browsing   0 members

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