How do I run an event after a loop

0 favourites
  • 7 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hey,

    As you can see in the picture below - I want the following to happen;

    • Pipe_base is creased and it spawns Pipe_tubing
    • Pipe_tubing grows by 2 height 100 times
    • Then as the loop ends Pimp_pump spawns on top of the Pipe_tubing (image point 1)

    at the moment the Pipe_pump is spawning straight away before the loop has completed. Is there a way of doing this? I've tried using a for loop as well...

    Thanks

  • you can try with a subevent eg systeme compare two values loopindex=100: action

  • Hi,

    I just tried your suggestion (compare two values [loopindex = 100]) as a sub event of "on created" and also as a sub event of the loop. Neither spawns a Pipe_pump at any time.

    Thanks

  • just add local variable (eg "Loop")

    on event system repeat 100 times, add action: add 1 to "Loop"

    add sub event to the loop : compare "Loop" = 100 : spawn pipe....

    set "Loop" = 0

  • The final index will be 99, not 100. Test as a sub-event of Repeat.

    Edit: Wait breaks the scoping, so this won't work.

  • Quick example here

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If I were you I would remove the repeat and instead make a new event for the growth and another one for the spawning of the pipe or simply add it in the growth event.

    You can do this by adding a variable to the Pipe_tubing called "Length" or something.

    Then you make an event like so:

    Every 0.1 second

    Pipe_tubing.Length < 100

    For each Pipe_tubing

    ----Add 2 to Pipe_tubing.Length

    ----Set Pipe_tubing.Height = Pipe_tubing.Height + 2

    ----If (Pipe_tubing.length = 100)

    -------- Spawn Pipe_pump

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)