Jump to content

on tap


Recommended Posts

I have a sprite jumping if the spacebar is pushed but i also want the same to happen on a mobile if the screen is tapped


cursors = this.input.keyboard.createCursorKeys();

this.jumpButton = this.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR) || this.input.onTap.add(onTap, this);

 what am i missing?

Link to comment
Share on other sites

you could use :

this.spaceKey = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); // spacebar

this.actionButton = this.add.button(this.game.width - 200, this.game.height - 200, 'actionButton');      // show a jump buttn on screen

           this.player.customParams.mustJump = true;
        }, this);

          this.player.customParams.mustJump = false;
        }, this);

and in the update function :

  if((this.spaceKey.isDown || this.player.customParams.mustJump) && this.player.body.touching.down) {
       //put your jump info here


Link to comment
Share on other sites


  • Recently Browsing   0 members

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