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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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