Timers

In this tut I'll go over Timers a little. Right click object> Add>Behavior>GENERAL>Timer.
While they aren't that complicated they let you get away from the asynchronous stuff by letting you add multiple timers including repeating ones.

Due to the preference for being able to instance objects there is no set method to make a timer that isn't somewhere in the editor. Of course that's not a real big deal as you can just think and name it however you like. If you want to make some type of global control timer, go right ahead. Likewise you can add the behavior to any object, just keep in mind it has to exist on the layout.
Also understand that the dot effect in the source is done using the PolkaDot effect applied to a layer.

You can add timers to all of your objects.
Tweens as well. It shouldn't add much overhead... unless of course you have thousands of instances running simultaneously.







The events:
+ System: On start of layout
-> System: Wait 0.25 seconds
-> Text: Tween "t0" value from 10 to 0 in 10 seconds (Default, destroy: No, loop: No, ping pong: No, repeat count: 1)
-> Sprite: Start Timer "yellow" for 5 (Once)
-> Sprite: Start Timer "green" for 10 (Once)
-> Sprite: Start Timer "bleep" for 1.0 (Regular)

So visually it would be nice to see the text actually at 10. Hence the wait 0.25
Lazily its easier to make a timer with a Tween as we can set it to go from 10 to 0. Timers just go up.
If we want to make things hard we could make an action in the yellow timer to start the green one, but again the lazy method of accounting for the second green time works just as well.
Then being ultra lazy we can make a repeating timer.

+ Text: Is Tween "t0" playing
-> Text: Set text to int(Text.Tween.Value("t0"))
We don't want to show any decimals. so use int()

+ Sprite: On Timer "yellow"
-> Sprite: Set color to rgb(255, 255, 0)
-> Text2: Typewriter text "ready?" over 0.25 seconds
-> System: Wait 3 seconds
-> Text2: Typewriter text "set?" over 1 seconds
When you think about it we already use a bunch of timers that are built in.

+ Sprite: On Timer "bleep"
-> Audio: Play 347167__davidsraba__bleep-sound.webm not looping at volume 0 dB (stereo pan 0, tag "")
The bleeping timer.

+ Sprite: On Timer "green"
-> Sprite: Set color to rgb(0, 255, 0)
-> Sprite: Stop Timer "bleep"
-> Text2: Typewriter text "Workout!" over 1 seconds
-> System: Wait 1.0 seconds
-> Sprite: Set animation frame to 1
-> Sprite: Tween "" property Width to 0 in 0.5 seconds (Default, destroy: No, loop: Yes, ping pong: Yes, repeat count: 1)
-> Sprite: Tween "" property Color to rgb(255,0,0) in 2 seconds (Default, destroy: No, loop: No, ping pong: No, repeat count: 1)
Then stop the bleeping(repeating) timer

Find the source here





Comments