nicwins Posted March 24, 2017 Share Posted March 24, 2017 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 More sharing options...
nicwins Posted March 25, 2017 Author Share Posted March 25, 2017 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 More sharing options...
nicwins Posted March 25, 2017 Author Share Posted March 25, 2017 I have a follow up question if anybody can figure it out: Can you have some (not all!) of the frames in the enemy animation cause damage to the player? Link to comment Share on other sites More sharing options...
Recommended Posts