I've organised the different stages of play in groups, with the idea that only one group should be active at any point.
This comes from my background as a scripter, where i would use State machines.
So the structure is like this :
Title (self expl.)
Setup (loads the objects of the game)
InitPlay (launches a new ball with random angle)
Game (when you actually play)
Score (self expl., leads either to a new InitPlay or to the end screen, depending if one player has reached the points limit)
Ending (You win! screen, brings back to Title)
I'm aware that maybe groups were not intended for such things. However, it works quite well. Only one group is active at a time, so the different sets of events are enabled oir disabled depending on the context.
My problem occurs when using the Wait action.
For example, in the Initplay group, i want to reset the ball position, make it visible, and wait a bit before lauching it, so that the players have some time to get ready.
The way I understood the wait action is that it waits a number of seconds before running the next action.
So what I expected was :
the program enters the only active group,Initplay.
It resets the ball's position and makes it visible (every tick, but that's not a problem)
Then waits, and comes back at the next tick.
In the meantime, checks all other groups entry events, but no other one should be active at that point.
When the wait is over, it moves on to setting angle and speed, only once, then changes the active group.
Instead, I get a situation where two groups are active at the same time, as if the system was executing the actions after the wait anyway.
Here is the project code :
I tried to keep it organised, but let me know if you have any questions !!