.isHitTestable (Can you visually see objects and turn off their listeners momentariliy)

Hi all,

I have two overlays in my game.

One that manages feedback to the player (Notifications Overlay), shows for 2 seconds then automatically closes.
The other manages the inventory back pack of items the player has collected (Inventory Overlay).

My game works perfectly, if the player interacts slow and steadily.
But…
If the player is really quick between clicking on an object that they can not use yet, thus invoking the Notification Overlay to show, but then they quickly click on the Inventory Overlay, as the 2 seconds expire that the Notification Overlay is programmed to show for, it’s scene Destroy event is also closing the Inventory Overlay, its highly annoying.

To solve this problem, I was hoping to temporarily block/prevent the ability for the player to be able to click on the parent scene objects (like the back pack button which opens the Inventory overlay), whilst the Notification Overlay was on screen.

I was attempting to use the groupMain.isHitTestible = false,  function on the parent scene’s objects, to temporarily disable them. But this only works if I set the group to invisible, which I do not want to do.

Is there a way to achieve this, keeping everything visible, but yet momentarily “removing” the ability to tap/touch/hit the objects??

Thanks
Angela
 

You can simply :removeEventListener() when you don’t need it and add it back again when you do.

Alternatively, you could place an invisible rect on top of those objects and give it isHitTestable = true and set its function to just return true at which point it will stop the events from propagating. You can also give your objects a “canTouch” value that you set to false when you don’t want the object to be touchable. Then you’d set this “if event.target.canTouch then” at the start of your touch listener.

Thanks… I did try this, but it was on a group and a number of child objects within that contained their own unique event listeners. 

So when I wanted to reinstate, I had multiple items to manage, and when the overlay was called on a different scene, that contained different objects again, things just seemed might confusing.

I did create a work around in the end, which technically and visually works, but is ethically (I think) is messy.

I hid the parent group, which disabled the objects, preventing two overlays from fighting with one another, thus solving the problem, but this visually made things appear and disappear on screen (for no reason) from the players visual perspective. So I created a fake button image in the overlay, to retain visual consistency, it now looks and does what it is ment to,  but as a solution I think I could find a better solution in the long run.

Thanks for taking the time to reply :slight_smile: