Jump to content

player sprite still stuck at last frame of stopped animation, not default sprite


Recommended Posts

So the problem i am having is that I expect the sprite to be his idle self when no up key is pressed and when an up key is pressed, obv the animation should play. Thing is, after the first time UP is pressed, the animation playes BUT the sprite stays in player_jump.png and not idle pose (default sprite). 



  create: function () {    this.player = this.game.add.sprite(this.game.width/2, this.game.height/2, 'player', 'player2.png');    this.player.animations.add('jump', [//        'player2.png',        'player_jump.png',        ], 20, false, false);  },



      if(this.cursors.up.isDown) {        this.playerJump();        this.player.animations.play('jump');      }      else if(this.cursors.left.isDown) {            this.player.body.velocity.x = -BasicGame.ACCELERATION;      }      else if (this.cursors.right.isDown) {            this.player.body.velocity.x = BasicGame.ACCELERATION;      }      else {            this.player.body.velocity.x = 0;            this.player.animations.stop();      }
Link to comment
Share on other sites


  • Recently Browsing   0 members

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