Diego Mellizo

Possible bug: button doesn´t work when moved off-screen to on-screen.

Recommended Posts

Context: in my game i got the setup you can see in the image. I got an image larger than the window, so i'm able to displace the image with the window's scroll bar, in the lower part of the image I got a button so it's initially hidden.

Problem: When I scroll down to see the button and put the pointer over it, it doesn't work for a few seconds (it doesn't execute input events. No hand cursor), after moving the cursor a little while over the button, it works again. I also checked the variables "visible" and "inputEnabled" in the update() but they are always true, so I suppose Phaser do something else to disable elements which are off-screen, and re-enable them once they are on-screen. Any suggestion would be highly appreciated.

bugBtn.jpg.4d2c61bae11d02cbd8d7013fc141b628.jpg

Share this post


Link to post
Share on other sites

Thanks for your response. I tried putting "game.input.activePointer.dirty = true;" inside the update function, but it's still not working. I also tried scrolling the window using the mouse wheel while holding and wiggling the pointer over the image, same result. Additionally, i did the test putting the pointer over the button and maintaining it static (no wiggling), after the second or third click it works, it's like it has a delay (maybe after it enters the screen) before it gets active.

Share this post


Link to post
Share on other sites

Other way to handle it - make the button invisible. Not sure if you can still click it but if you can in the code for the button do soemthing like 

if this.alpha == 0

{

   return

}

 

Never tried it but that might work. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.