Sign in to follow this  

Double Jump Phaser 3

Recommended Posts

Hi, I'm new to developing games with Phaser3. I am going crazy, for days I have been looking for a way to do a 'double jump'. and I can't ...
I found many questions similar to this one here, but none gave me a concrete solution ...

I would like the player to double jump if I double-click the 'up' cursor.

Please help me.

function update() {
if (cursors.left.isDown) {
player.setVelocityX(-130);'left', true);
} else if (cursors.right.isDown) {
player.setVelocityX(130);'right', true);
} else {
player.setVelocityX(0);'idle', true);
if (cursors.up.isDown && player.body.touching.down) {

Share this post

Link to post
Share on other sites

Hi @Adele welcome to html5gamedevs 😄. Without seeing the context of your code I cannot help that much. But, I will give it a try. This is how I would implement a double jump on my game.

// create a variable canDoubleJump

function update() {
    if (this.keys.left.isDown) {
    } else if (this.keys.right.isDown) {
    } else {'idle',true);

    const didPressJump = Phaser.Input.Keyboard.JustDown(this.keys.up);

    // player can only double jump if the player just jumped
    if (didPressJump) {
      if (player.body.onFloor()) {
        // player can only double jump if it is on the floor
        this.canDoubleJump = true;
      } else if (this.canDoubleJump) {
        // player can only jump 2x (double jump)
        this.canDoubleJump = false;



Edited by geocine

Share this post

Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.