Timer Events and Animation
An app is a set of event handlers. When something occurs, perform some instructions (blocks).
Event Types
UI events
-
when Button.Click
-
when Canvas.Touched, when Canvas.Dragged
External Events
-
when Texting.MessageReceived
-
info from web, GPS sensors
Now we'll consider timer events, i.e., when you want something to happen as time passes. A Clock component is used.
Clock properties
-
timerInterval -- default is 1000 (ms)
-
timerEnabled -- default is true, meaning Timer event will trigger every timerInterval
Image sprites
Within a canvas, you can place an ImageSprite or Ball. They only "live" within a Canvas. Ball and ImageSprite have the same behavior. ImageSprite is different in that you can specify an image file for it.
Instructor demo: A sprite that moves back and forth across the screen
-
Move sprite one second after a button is clicked
-
Move sprite back and forth continuously after button is clicked (alternatively when app begins)