Wait in repeat?

0 favourites
  • 12 posts
  • Any easy way to use wait in Repeat? My req is create object though function after a certain delay intervel.

    (I found a 10 years old post but could't make it work so hence posted)

    Tagged:

  • Do not use wait in loops (preferably do not use wait ever).

    Loops complete in their entirety within a tick, or effectively instantaneously. For anything that needs to be done over time, use the timer behavior.

    I found it very helpful to learn to use trigger conditions for everything that happens at certain time.

    If you must use a wait, use "Wait loopindex seconds", and put it before the action.

  • Thank you,

    * On function 'SpawnFun'

    ----+ System: Repeat 10 times

    -----> System: Wait LoopIndex seconds

    -----> System: Create object SpriteObj on layer 0 at (SpawningPoint.X, SpawningPoint.Y), create hierarchy: False, template: ""

    System: Wait LoopIndex seconds is what I was looking for.

    I was Reading this thread

    https://www.construct.net/en/forum/construct-3/how-do-i-8/wait-inside-forrepeat-loop-157049

    One doubt: why would one use the Timer behavior over 'Wait LoopIndex seconds' for this scenario? Is it because if you want to control the time more precisely, as LoopIndex doesn't allow you to control the amount of delay precisely?

    Is that correct?

  • Any easy way to use wait in Repeat? My req is create object though function after a certain delay intervel.

    (I found a 10 years old post but could't make it work so hence posted)

    Repetition cycles are instantaneous, it's a feature of the engine. There is a trick to slow it down you add a loopindex to the wait. This makes the engine stop the repetition and come back to it after time.

    But it is better to learn how to use timers as my colleague wrote above. It is a more correct way.

  • Damn, it's been more than two hour, and my previous responce has not been published yet,

    anyways, just futher one question

    How do i detect the repeat is done, I want the CrownObj to be spwan only after the repeat 5 times is done?

  • I find the first option to be more correct and flexible.

    The second option according to your conditions, but it is a crutch.

  • Hi igortyhon, initially I tried using Sprite.count, but the problem is I need to call it multiple times on the same layout at different spawning points, so it's not that reliable. Thus, I dropped it and went the function way.

    Now almost everything is done, but the only issue is coming up when creating the CrownObj. I don't know why. It technically should be called once the repeat is done, right? I found a suggestion in this link.

    construct.net/en/forum/construct-3/how-do-i-8/detectwhen-loop-ended-150110

  • You can't do that.

    You will check the lupindex and it will always be zero.

    Use the first method from the screenshot and customize it for yourself.

  • Here is a variant using a timer, it can be used many times and put into a spawn function with customizable parameters.

    We spawn the object that is responsible for spawning, and after completion we remove it

  • Thank you, igortyhon. The solution you provided with the timer works great, so does the non-timer way.

    spawn function with customizable parameters.

    Actualy I could't able to make it to the function, as

    + Timer: On Timer "xyz"
    

    it refused to go inside the function's sub event, thus could't make it to the function.

    What I feel is that using a timer might be overkill for my requirement, (but I could be wrong) so I'm now stick with the non timer way and with function because it will help to call it anywhere with parameters.

    So, I posted a separate question that's related to the current query but deals with functions in general. So, I'm hoping that you and oosyrag can please check that.

    construct.net/en/forum/construct-3/how-do-i-8/issue-calling-function-178880

  • I think I understand what you want, I'll think about how to make it pretty and reply in that thread.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you, i really like to pull this using only function and parameters. i dont know why the issue coming with with when calling the same function multiple times with different parameters.

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