light ((.5 -1 1))
To make a timer loop, you want it to start again when it reaches the back:
// a 5 second timer timer ((5.0),when(,("timer finished")),)
You can also make the timer go back and forth between the front and back.
the reverse message makes the timer play backwards.
the front event is triggered when the timer reaches the beginning, and the start message
starts it playing forwards again.
// a 1 second back-and-forth timer timer clock ((1.0),, when(,("tick"),), when(,("tock"),) )
A simple use of the timer is to repeatedly move an object between two positions. We can do this by sending a message to an object node when the timer reaches the front or back. To try out these examples, make a simple object to represent a clock hand, or download this example file: clockhand.pfb.
// ticking clock, with geometry
light ((.5 -1 1))
timer clock ((1.0),,
when(,clockhand.(0 -45 0),),
when(,clockhand.(0 45 0),)
)
object clockhand ((clockhand.pfb),(0 5 5),(0 45 0))
| <-- Previous: Timer] | Next: Multiple values--> |