-
I experience (at least for me) unexpected behavior with clicks: I have a menu, upon clicking a button I start the game by changing
Otherwise the code is the same. Can anyone explain why this happens? I reproduced the behavior in this example (Bevy 0.6):
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
If you add the Hence, when using states, the |
Beta Was this translation helpful? Give feedback.
If you add the
ReportExecutionOrderAmbiguities
resource to your world, you'll see thatwatch_menu_clicks
andwatch_game_clicks
are ambiguous in both cases. By coincidence of how the executor's ordering runs, it happens that when it's not using the state handling,watch_game_clicks
runs first in a frame; when you are using the state version,watch_menu_clicks
happens first.Hence, when using states, the
watch_game_clicks
runs in the same frame as you switch to being in game, so the button wasjust_pressed
in that frame. When not using states,watch_game_clicks
runs the frame after, whilst the button was still being pressed, but it's 'just_pressed'-ness had been cleared.