Operation Spark Posted March 16, 2016 Share Posted March 16, 2016 I'm trying to load an animation from an atlas, and I'm pulling my face off with frustration! I've used TexturePacker to generate an atlas, I've tried using both type ARRAY and JSON_HASH, here's an example of the ARRAY output: // in player.json, the frames are represented as such, from frames 0001 to 0021: { "filename": "run0001.png", "frame": {"x":206,"y":222,"w":80,"h":103}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":3,"y":0,"w":80,"h":103}, "sourceSize": {"w":83,"h":119} } // in the game's javascript: function preload() { game.load.atlas('player', 'asset/player/atlas-array/player.png', 'asset/player/atlas-array/player.json'); } function create() { var player = game.add.sprite(0, 0, 'player'); player.animations.add('run', Phaser.Animation.generateFrameNames('run', 1, 21) , 30, true); // we crash here with TypeError: Cannot read property 'index' of undefined... at phaser.min.js:20 player.animations.play('run'); } What on earth am I doing wrong? Thanks! Link to comment Share on other sites More sharing options...
Operation Spark Posted March 16, 2016 Author Share Posted March 16, 2016 Nevermind, I needed the settings: animations.add('run', Phaser.Animation.generateFrameNames('run', 1, 21, '', 4) , 30, true); The docs could be MUCH clearer, there's no explanation of these arguments, here:http://phaser.io/examples/v2/animation/multiple-anims Link to comment Share on other sites More sharing options...
stupot Posted March 16, 2016 Share Posted March 16, 2016 Have you looked through the online docs: http://phaser.io/docs/2.4.6/index Here's where the info on generateFrameNames is: http://phaser.io/docs/2.4.6/Phaser.Animation.html#.generateFrameNames Finding what you're after in the docs can be difficult for a newcomer. Link to comment Share on other sites More sharing options...
Operation Spark Posted March 17, 2016 Author Share Posted March 17, 2016 Thx!!! Link to comment Share on other sites More sharing options...
Recommended Posts