Jump to content

Jump animation while the character is jumping


NUGA
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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