NUGA Posted May 16, 2018 Share Posted May 16, 2018 I'm trying to make a Mario styled platformer, and i'm running into a problem where the jumping animation is overridden by the walking animation when pressing the up and right(or left) arrow keys together. Here's what i have in regards of the update and playing the animations. The character sprite is loaded as a spritesheet if it makes a difference. if(this.cursors.right.isDown){ this.mario.play('walk', true); this.mario.flipX = false; this.mario.body.setVelocityX(500); } else if(this.cursors.left.isDown){ this.mario.play('walk', true); this.mario.flipX = true; this.mario.body.setVelocityX(-500); } else{ if(this.mario.body.onFloor()){ this.mario.play('stand'); }else { this.mario.play('jumping'); } this.mario.body.setVelocityX(0); } if(this.cursors.up.isDown && this.mario.body.onFloor()){ //this.mario.play('jumping'); this.mario.body.setVelocityY(-600); } Link to comment Share on other sites More sharing options...
squilibob Posted May 17, 2018 Share Posted May 17, 2018 If you change your walking animation to include a check to see if the sprite is on the floor then it should work this.mario.body.onFloor() && this.mario.play('walk', true); Link to comment Share on other sites More sharing options...
Recommended Posts