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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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