Using System.Wait and Groups

0 favourites
  • 2 posts
From the Asset Store
Add calm and a lounge vibe to your games with these 8 tracks
  • 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 :

    mediafire.com/download.php

    I tried to keep it organised, but let me know if you have any questions !!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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"

    or

    • Deactivate group "InitPlay"
    • Activate group "Game"
    • Wait 1 second
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)