Add Delay Function

Hi, I am currently working on developing on a game on which I am working since long time. I know and I can create a delay using clock but can you Devs please import a new function in control
as delay and a number box attachable to it. So we can create a delay between two procedures or function.Please look ahead for this.

3 Likes

@Hrishikesh_Salokhe You can use the GetMillis procedure in clock. You can make two varibles, one for current milliseconds timestamp say currentMillis and another to compare the current Millis previousMillis. Once the comparison is done, update the variable previousMillis with the value of currentMillis. In this way, you can set delay of certain milliseconds.

1 Like

Not sure that is great advice @sarkar. You should set any delay with a clock timer.

You can do lots with a Clock.

See this example for juggling three things simultaneously using a single clock.
https://groups.google.com/forum/#!msg/mitappinventortest/BOj2-ThEe3s/VlmXdcVOAgAJ

Yes, the method uses a clock timer.

This method is regularly used in embedded system codes, where you have a single hardware timer. Using a complete delay (aka pause), it halts the whole program. On the other hand, by creating routines for comparing milliseconds, you can set variable delays. Even in the above case, if the delays require a sync, then using millis comparison would be helpful.

@sarkar @Hrishikesh_Salokhe
Why is a wait procedure generally a bad idea?
The model of event processing in App Inventor by @Franklyn_A_Turbak
Please Wait method byScott

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

Woah! Thanks @Taifun. Yep, @TIMAI2 you were right.
There’s no guarantee the delay would work as expected in the method, and unlike embedded system, app is not running on a real-time system.

This might be the simplest implementation if you don't mind adding clocks, be reminded to un-check TimerAlwaysFires and TimerEnabled


Effectively a for loop with iteration 5, while loop is similar.

4 Likes

Thanks. its working great.

hii also have the same doubt i want to make a label visible an invisible few times

Please see here:

Call from wherever you want...

Please read above (posts/links) with regard to event processing. You cannot rely on this method.

as already said earlier

therefore the correct wait method is this (by Scott)

Taifun
PS: I will close this thread, everything already has been said...

3 Likes