Using System.Wait and Groups

Get help using Construct 2

Post » Wed Feb 08, 2012 4:41 pm

So, I'm working on a simple Pong game as afirst project with Construct2.

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 !!maldine2012-02-08 16:45:00
Posts: 2
Reputation: 529

Post » Wed Feb 08, 2012 5:25 pm

The thing most people miss about the "Wait" action is it only pauses the current event, not the entire game! So the rest of your events continue to run while it is waiting.

So if you have:

- Wait 1 second
- Deactivate group "InitPlay"
- Activate group "Game"

then the group "InitPlay" continues to be activated and its events are running for that 1 second. Perhaps you wanted:

- Deactivate group "InitPlay"
- Wait 1 second
- Activate group "Game"


- Deactivate group "InitPlay"
- Activate group "Game"
- Wait 1 second
Scirra Founder
Posts: 23,262
Reputation: 183,689

Return to How do I....?

Who is online

Users browsing this forum: Fatsquid, mrtumbles and 0 guests