Jump to content

phaser 3 touch listeners


bobnobilo
 Share

Recommended Posts

Hey guys, 

am having some trouble with a button that I've implemented with a sprite on touch screens.

when the button is pressed, and the user swipes their fingers outside of the bounds of button the pointerout etc event listeners are NOT fired leaving the button in a "pressed" state. This also occurs when the user presses the button on the border.

Anyone got any ideas?

Link to comment
Share on other sites

Sorry, should of realised that I would have needed to post some code.

Here's the button that I've implemented. 
 

class Button extends Phaser.GameObjects.Sprite{

    constructor(scene, x, y, image){
        super(scene, x, y, image);
      
        this.isPressed = false;
       
        this.setInteractive();
        this.on("pointerdown", this.pressed);
        this.on("pointerup", this.unpressed);
        this.on("pointerout", this.unpressed);

    }

    pressed(){
        this.isPressed = true;
    }

    unpressed(){
        this.isPressed = false
    }
   
}

 

Any ideas would be appreciated

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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