Jump to content

How to write a animation loader for phaser.io ?


Dave Newton
 Share

Recommended Posts

Hello,

I am using my own json animation format and editor for all my games* and I'm starting a project with phaser.io.

I did not find any clue how to write custom animations loader with phaser. The existing parsers are called in Cache implementation ( https://github.com/photonstorm/phaser/blob/8e03fbd5a53ba1a9f094fa0bd7216e7910df3dc0/src/loader/Cache.js ), I wonder if this is even possible. If it's not, I could write a converter, but I did not find any documentation on current json/xml format expected by phaser.

Has somebody some experience with custom format loading with phaser.io?

 

Sample file: https://github.com/devnewton/newton_adventure/blob/master/game/data/default_level_data/hero.json

687474703a2f2f696d672e6c696e757866722e6f

*: http://newtonadventure.bci.im and http://en.geekygoblin.org/ned-et-les-maki/

Link to comment
Share on other sites

You can load your .json file with standard Phaser loader (load.json()) and do whatever you need with it. But, do not expect Phaser to recognize your format - you will have to load texture with images as well and then you will have to create frames for it manually with regard to your .json metadata.

In fact, looking into your .json metadata, you are mixing frame definitions and animation definitions into one file. Hard way is to code everything by yourself (your loading routines, creating fames, your animation systems). Half-hard way is to get rid of frame defs (uvs) from your file and use standard atlas or spritesheet loading (then it would be enough to reference frames with atlas name from your .json - no need to add frame uvs). Easy way is to use Phaser features and adjust your tool to produce some result you can easily turn into something Phaser understands.

Link to comment
Share on other sites

Thank you Tom Atom.

Quote

Easy way is to use Phaser features and adjust your tool to produce some result you can easily turn into something Phaser understands.

Do you know where I can find a description of formats expected by Phaser? I did not find it in API documentation:

«Must be in Array format» «Must be in JSON Hash format.» «Must be in Pyxel JSON format.» But no clue about what these formats are :-(

http://phaser.io/docs/2.6.2/Phaser.AnimationParser.html

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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