Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sgsdxzy |
I am desgining a puzzle game, which involves the player click on on the right place (metas in RichTextLabel and CollisionShape of Area2D) to proceed.
This games features literarily “everthing clickable” that even some borders of GUI elements are clickable, and the screen is supposed to be littered with clickable elements.
And I want to notify the player that he clicked on the wrong place, so i need to know that the player clicked but not on the right place. There will be so many clickable elements, and their position may change depends on the chosen game language and window size, so it is impossible to make a “reverse mask” that covers every wrong place.
How can I filter every click event that is not on the right place?
My experiments so far:
_unhandled_input()
is after GUI elements consumes inputs, and clicks on GUI elements, even not on the right place, will be consumed.- Setting GUI elements mouse filter to “Pass”, however correct clicks will also be passed, and I only want the “you clicked on the wrong place” message to display when clicked not on the right place.
- Get all inputs via
_input()
, and if it is on the right place, the corresponding callback will mark this input as “right”. If no callbacks mark this input, it is “wrong”. However I don’t know when and where are all callbacks are guaranteed to finish so I can judge it’s right or wrong. I could use a small time delay to expect all callbacks to finish, but that will be the most ugly thing to do.