ImageSprite
Definition
A ‘sprite’ that can be placed on a Canvas
, where it can react to touches and drags, interact with other sprites (Ball
s and other ImageSprite
s) and the edge of the Canvas
, and move according to its property values. Its appearance is that of the image specified in its Picture
property (unless its Visible
property is false
.
To have an ImageSprite
move 10 pixels to the left every 1000 milliseconds (one second), for example, you would set the Speed
property to 10 [pixels], the Interval
property to 1000 [milliseconds], the Heading
property to 180 [degrees], and the Enabled
property to true
. A sprite whose Rotates
property is true
will rotate its image as the sprite’s heading changes. Checking for collisions with a rotated sprite currently checks the sprite’s unrotated position so that collision checking will be inaccurate for tall narrow or short wide sprites that are rotated. Any of the sprite properties can be changed at any time under program control.
Properties
- Enabled
- Controls whether the
ImageSprite
moves when its speed is non-zero. - Heading
- The
ImageSprite
’s heading in degrees above the positive x-axis. Zero degrees is toward the right of the screen; 90 degrees is toward the top of the screen. - Height
- The height of the ImageSprite in pixels.
- Interval
- The interval in milliseconds at which the
ImageSprite
’s position is updated. For example, if theInterval
is 50 and theSpeed
is 10, then theImageSprite
will move 10 pixels every 50 milliseconds. - Picture
- Specifies the path of the sprite’s picture.
- Rotates
- If true, the sprite image rotates to match the sprite’s heading. If false, the sprite image does not rotate when the sprite changes heading. The sprite rotates around its centerpoint.
- Speed
- The speed at which the
ImageSprite
moves. TheImageSprite
moves this many pixels everyInterval
milliseconds ifEnabled
istrue
. - Visible
- Sets whether sprite should be visible.
- Width
- The width of the ImageSprite in pixels.
- X
- The horizontal coordinate of the left edge of the ImageSprite, increasing as the ImageSprite moves right.
- Y
- The vertical coordinate of the top edge of the ImageSprite, increasing as the ImageSprite moves down.
- Z
- How the ImageSprite should be layered relative to other Balls and ImageSprites, with higher-numbered layers in front of lower-numbered layers.