Timer event

For this kind of event, there is an on-time actor. This actor works together with the face's rate facet, which sets the rate at which the event takes place, either expressed in:

  • Rate per second, such as one time per second: rate 1, so rate 50 is 50 times faster than rate 1
  • As a time! value, such as rate 0:00:03 for every 3 seconds

At each tick, the on-time actor is executed. Here are a few simple examples. Note how we can achieve some primitive animation effects by changing the offset in an on-time actor:

;-- see Chapter09/timers.red:view [    size 400x400    b: button 80x30 green "Catch me" rate 50         on-time [b/offset: b/offset + 1x1]        on-down [quit]    t1: text txt rate 5        on-time [either t1/text = "" [t1/text: txt][t1/text: ""]] t2: ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.