How do I Stop Loop

0 favourites
  • 3 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • Hello guys,

    A simple thing that I can not do, can you help me? He wanted that when a VARIABLE had the value X, the FOR loop was interrupted.

    I did it, but it did not work:

    global VAR = 3

    System: For "" from 1 to 10

                   system: VAR > LoopIndex

                                  system: Create object Sprite on layer at 360, 450 - 40 * LoopIndex

                   system: Else

                                  system: Stop Loop

    But it does not work. Can anyone help?

    Thank you.

  • Hello guys,

    A simple thing that I can not do, can you help me? He wanted that when a VARIABLE had the value X, the FOR loop was interrupted.

    I did it, but it did not work:

    global VAR = 3

    System: For "" from 1 to 10

                   system: VAR > LoopIndex

                                  system: Create object Sprite on layer at 360, 450 - 40 * LoopIndex

                   system: Else

                                  system: Stop Loop

    But it does not work. Can anyone help?

    Thank you.

    It works but you need to make sure you put the Loop under any "Trigger" a Function can be good swell or A variable where you can turn it (on or off ) other ways the Loop will keep running none stop because you comparing against the (LoopIndex) the loop stops when is > 3 but starts again from 0 because the Top Event Condition is always true after you stop the Loop >>> For "" from 1 to 10 will be like Every thick if is true do this

    Or another way to stop it the way you do it is on

    The Else>> StopLoop & one more Action set global VAR = -1

    but the proper way will be to put it under a trigger or Function or etc....

    https://www.dropbox.com/s/7j8had08tlgh3sg/Stoop%20The%20Loop.capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To add to tarek2's answer:

    Your code works, but you can do it much simpler:

    System: For "" from 1 to VAR -> Create object Sprite on layer at 360, 450 - 40 * LoopIndex

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