Jump to content

¿how to optimize my code for double jump?


jopcode
 Share

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 = this.game.input.keyboard.addKey(Phaser.Keyboard.UP);
        if(this.upKey.downDuration(20)) {
          if(this.jumpCount < this.jumpMax) {
            this.jumpCount++;
            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

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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