¿how to optimize my code for double jump?

Recommended Posts

Hi guys, i have a code for the double jump, but sometimes this don't work correctly and my player can't jump, I'm noob with phaser, and someone can help me to optimize my code please

This is my code(jumpCound and jumpMax has been declared in create function):

  this.upKey =;
        if(this.upKey.downDuration(20)) {
          if(this.jumpCount < this.jumpMax) {
            this.player.body.velocity.y = -500;
            console.log(this.jumpMax + ' ' + this.jumpCount);
        if(this.player.body.blocked.down || this.player.body.touching.down) {
          this.jumpCount = 0;

This code has been declared in UPDATE function

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.