Jump to content

Super frustrated with Atlas!


Operation Spark
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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