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

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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