Repeat an action x times within a function? [Solved]

0 favourites
  • 3 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hi all. Sorry to post this as I'm sure it's a simple solution, but I searched for every combo of the words on the forums + manual and still can't figure this out.

    Basically I want to repeat an action x times within a function, but nada. I know I can call the function outside x number of times and that would be dandy, but then it became a matter of curiosity as to why this doesn't work.

    Can anyone explain? Do functions simply run everything inside just once no matter what?

    Thank you in advance!


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It repeats 30 times, but this way it repeats 30 times in 1 tick.

    I suppose you want to see 'those 30 repeats' happen, then you must give the system the chance to redraw. Redrawing the screen happens on the end of the tick.

    To do this, you basecaly use the tick-loop. The events run top down (kinda). 1 top down = 1 tick. And it keeps 'ticking' as long as the game runs.

    So you need a variable ... lets say 'counter' ... a number.

    When you need to the repeat to happen, set it to 29. On the place where you now do the function call.

    Now just ....

    New event with condition ...

    System compare 2 values ... 'counter' ... > ... zero

    Actions ....

    Substract 1 from 'counter'

    All the other actions. from above.

  • Ah. Cool!

    That's awesome. It's working like clockwork now. Thanks a heap for the help 99Instances2Go!

    Here's how it's looking now:


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