Dave Newton Posted September 24, 2016 Share Posted September 24, 2016 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 *: http://newtonadventure.bci.im and http://en.geekygoblin.org/ned-et-les-maki/ Link to comment Share on other sites More sharing options...
DegGa Posted September 24, 2016 Share Posted September 24, 2016 Use something called: Spritesheet. which is like this:(Put all of the animations in one image) And you can load it using: game.load.spritesheet(key, url, frameWidth, frameHeight) You find more info here and here. Link to comment Share on other sites More sharing options...
Dave Newton Posted September 24, 2016 Author Share Posted September 24, 2016 Thank you DegGa, but if I wrote an animation software that's because simple spritesheet with fixed frame size did not meet my needs :-) Link to comment Share on other sites More sharing options...
Tom Atom Posted September 25, 2016 Share Posted September 25, 2016 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 More sharing options...
Dave Newton Posted September 26, 2016 Author Share Posted September 26, 2016 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 More sharing options...
Recommended Posts