(MAI) Image Sprites and the Clock Timer Lesson
Image Sprites and the Clock Timer
Animating Objects
A sprite is a graphical object placed within a canvas where it can react to touches and drags, interact with other sprites and the edge of the Canvas. They are located in the Drawing and Animation section of the Palette. You can choose a Ball or an ImageSprite.
A ball component is a particular kind of sprite that looks like a ball. An ImageSprite is a component for animating an object. The image for the object is specified in the Picture property for the ImageSprite. The Ball and ImageSprites react to touches and drags, interactions with other sprites, and the edge of the canvas.
The difference between a ball and an image sprite is that the ImageSprite can get its appearance from an image, while a ball's appearance can only be changed by varying its PaintColor and Radius properties.
An ImageSprite's speed is in pixels/second. It is determined by two properties. The interval property specifies how often the sprite will be moved. The Speed property specifies how many pixels the sprite will move each interval.
The heading property of an object specifies the direction it moves. It has a range of 360 degrees. Review the chart to learn the movement associated with the heading values.
You can also use the set Ball.Heading block to change the direction of the ball during the program.
Clock
One way to specify animation is to change an object in response to a timer event. Most commonly, you'll move sprites to different locations on the canvas at set time intervals. It works without involving any action from the user.
The internal time format used by the clock is called an instant. The clock's Now method returns the current time as an instant. The clock provides methods to manipulate instants, for example, return an instant that is several seconds, or months, or years from the given instant. It also provides methods to show the second, minute, hour, day, corresponding to a given instant.
[CC BY 4.0] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION