I don't get loops

This forum is currently in read-only mode.
From the Asset Store
Tap the ball, control it, avoid touching spikes and score higher!
  • Hi!

    I don't get loop.

    How do I use them?

    Can anyone upload an exsample .cap with some comments?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • They're really simple. They just repeat stuff.

    + On spacebar pressed

    + Repeat 5 times

    -> Add 1 to global variable 'test'

    When you press spacebar, 5 is added to 'test' (it adds 1 five times, instantly)

    + Start of layout

    + Repeat 100 times

    -> Create Star at random(640), random(480)

    Creates 100 randomly positioned stars on startup.

    There are some variations like For (loop over a range of numbers), For Each (repeat once for each instance of an object), and so on. You can read more in the Conditions article.

  • Okay, probably you may want to wait for some brainiac to explain it to you properly. And as I'm writing this I'm noticing mighty Ashley replying... I'll still reply anyway.

    I'd say you need loops where you want certain events/actions being executed many times a tick, instead of only once.

    I have uploaded a little example for you with a WHILE loop. We have a Global there called Outcome and we want it to have the value 0,1,2 or 3, which is Random(4) of course. But we also want to be able to dynamically exclude certain possibities. We define these with the Nono_a and Nono_b globals. The values set there are values Outcome must never have. So we cannot simply run Random(4), but we run it until the result will be different from Global Nono_a+b. And all this will happen in the same tick, thanks to the while loop.

    So if you run the example hit X and you will see the value will always be different from the ones defined in the Nono globals.

    I hope that was some help at all... maybe this example was horribly lame.

  • Thanks:) Now I get it. It has been a mystery to me since my MMF-days

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