How to have a repeating For Loop?

0 favourites
  • 15 posts
From the Asset Store
SynthWave Loop Pack
$7 USD
30% off
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies. For use in game and custom works.
  • Im trying to make a for loop repeat. Like it could go from 0 to 100 but then go back to 0 and repeat. Is this possible?

  • Create this loop inside a function

  • klabundee

    Ok, I tried that but it just lagged

  • Lagged?

    Can you post and image of your event sheat?

  • I have the loop structured like this. When I try to preview it or open it in debug it wont load.

  • You could put another For loop inside the first one. But the way you have it currently loops always and probably leads to an error.

  • yme

    You could put another For loop inside the first one.

    Im not sure what you mean by this, can you post an image of it?

  • I have the loop structured like this. When I try to preview it or open it in debug it wont load.

    You are calling the function every time that the loop runs...

    Inside the loop only set action.

    You have to set conditions to call the function.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have the loop structured like this. When I try to preview it or open it in debug it wont load.

    Do you realize what you are doing here? Everytime you call the function it calls itself 90 more times. Each of those 90 calls will call itself 90 more times, so 8,100 times so far, and will go on for infinity.

    This is why your browser will lag then crash.

    If you put a for loop by itself it will run every tick. Tick being dependent on framerate, but that could be between 40-60 times per second. So it will repeat on its own.

    If you want less than that then use every X seconds or put it in the function like you have it, just don't have it call itself for eternity.

  • Let me try to understand better.. what this for loop is supposed to do?

  • My bad - I thought the function call was nested in the loop, not after it.

    Either way, this will still try to call the loop an infinite number of times in the same tick producing the same result.

  • My bad - I thought the function call was nested in the loop, not after it.

    Either way, this will still try to call the loop an infinite number of times in the same tick producing the same result.

    Yes, its calling itself once every time it runs. Its not inside the loop.

  • > My bad - I thought the function call was nested in the loop, not after it.

    >

    > Either way, this will still try to call the loop an infinite number of times in the same tick producing the same result.

    Yes, its calling itself once every time it runs. Its not inside the loop.

    This will still call itself an infinite number of times most likely causing browser to crash

  • > > My bad - I thought the function call was nested in the loop, not after it.

    > >

    > > Either way, this will still try to call the loop an infinite number of times in the same tick producing the same result.

    >

    > Yes, its calling itself once every time it runs. Its not inside the loop.

    This will still call itself an infinite number of times most likely causing browser to crash

    Yes, sorry, maybe my last post was not clear.

    I wrote that the calling action was inside the loop, as I saw that I was wrong I deleted my post and wrote a new one agreeing with yours. It is an endless loop.

  • > > > My bad - I thought the function call was nested in the loop, not after it.

    > > >

    > > > Either way, this will still try to call the loop an infinite number of times in the same tick producing the same result.

    > >

    > > Yes, its calling itself once every time it runs. Its not inside the loop.

    >

    > This will still call itself an infinite number of times most likely causing browser to crash

    Yes, sorry, maybe my last post was not clear.

    I wrote that the calling action was inside the loop, as I saw that I was wrong I deleted my post and wrote a new one agreeing with yours. It is an endless loop.

    No worries, just trying to help!

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