Jump to content

My animation will not play


devx123x
 Share

Recommended Posts

I am trying to run an animation in phaser. I created the sprite and added the animation with the following code:

player = game.add.sprite(game.world.centerX,game.world.centerY,null); // parent spriteplayer.legs = game.add.sprite(50,50,'soldier',16); // child spriteplayer.legs.anchor.set(1,1);  //anchoring child spriteplayer.legs.animations.add('walk',[16,15,14,13],10,null,false); // The animation I want to playplayer.addChild(player.legs); // adding sprite as child

I run the animation with the following code:

player.legs.animations.play('walk');

The version of phaser I am using is 2.3, the build with arcade physics only. I am certain the issue is not with the spritesheet or the json atlas.

 

Edit: I just console logged 

player.legs.animations.currentAnim.isPlaying 

and it says true!

index.html

Edited by devx123x
Link to comment
Share on other sites

Upload your soldier.json + png files here. I suspect it doesn't use frame numbers, but frame names. Seeing this will confirm though.

Thank you so much Rich, this solved my problem. The funny thing was that I was able to create the sprite with a frame number and it worked fine.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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