Jump to content

Any1 been succesful at loading animation frames from Tiled???


nicwins
 Share

Recommended Posts

If I hard code an enemy...

var enemyData = {

health: 20,

attack: 40,

animationFrames: [1, 2, 3, 4, 3, 2, 1]

}

... it animates fine through the enemy prefab. But if I load an object with the same properties from a Tiled map - IT WONT WORK!

I know to convert the strings to numbers with:

this.data.attack = +this.data.attack;

But when I have an array, it doesn't seem to work :(

Link to comment
Share on other sites

I did it with the following code:

var animArray = data.animationFrames.split(',');
     for (a in animArray ) {
    animArray[a] = parseInt(animArray[a], 10);
     }

If anybody wants to know how its done, just converts it from a string to an array of integers :)

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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