Returns a Timer which will fire the :on-timer function one or more times (depending on the given arguments). In the :on-timer function, the id will be passed in the screen map. If a timer with that id already exists in the screen, it will be stopped and replaced with a new timer.
; wait 2 seconds and run once (add-timer! screen :spawn-enemy 2) ; wait 2 seconds and run forever at 10 second intervals (add-timer! screen :spawn-enemy 2 10) ; wait 2 seconds, run once, and then run 3 more times at 10 second intervals (add-timer! screen :spawn-enemy 2 10 3)
Source
(defn add-timer!
([screen id delay]
(doto (create-and-add-timer! screen id)
(.scheduleTask (task* screen id) delay)))
([screen id delay interval]
(doto (create-and-add-timer! screen id)
(.scheduleTask (task* screen id) delay interval)))
([screen id delay interval repeat]
(doto (create-and-add-timer! screen id)
(.scheduleTask (task* screen id) delay interval repeat))))