Nested loops question

0 favourites
  • 6 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • Say you make a nested loop with one inner, and one outer loop. How do you make an action happen after the inner loop runs? Like, say I wanted to increment a number every time the inner loop runs through, but I don't want the number incremented until after it has actually ran?

  • X is a variable

    X = 0 or whatever value you need it to start at.

    Try this:

    "For X to 100"

    ---"For 0 to 10"

    ---"Do whatever in the inner loop"

    Add 1 to X

    (You can just add a blank event underneath the inner loop, and it will run when the inner loop is done.

  • That's all great until you get to the part where you "add 1 to X". C2 doesn't seem to allow me to put an action within a loop after the inner loop, but before leaving the scope in which the inner loop exists. I am using the "repeat X times" loop events. Would using a different type of loop make a difference?

  • Would using a different type of loop make a difference?

    Nope. Select your repeat event, and press B. It will create black sub-event for the repeat event, now you can add whatever you wish to that.

  • Oooh, that's a dang handy shortcut! Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, thanks guys. I got it working, there was another bug interfering with what I was doing that made things more difficult to sort out. Thank you both, you were very helpful in this matter.

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