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

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...