Ball
Definition
A round ‘sprite’ that can be placed on a Canvas
, where it can react to touches and drags, interact with other sprites (ImageSprite
s and other Ball
s) and the edge of the Canvas
, and move according to its property values.
For example, to have a Ball
move 4 pixels toward the top of a Canvas
every 500 milliseconds (half second), you would set the Speed
property to 4 [pixels], the Interval
property to 500 [milliseconds], the Heading
property to 90 [degrees], and the Enabled
property to true
. These and its other properties can be changed at any time.
The difference between a Ball
and an ImageSprite
is that the latter can get its appearance from an image file, while a Ball
’s appearance can only be changed by varying its PaintColor
and Radius
properties.
Properties
- Enabled
- Controls whether the
Ball
moves when its speed is non-zero. - Heading
- The
Ball
’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. - Interval
- The interval in milliseconds at which the
Ball
’s position is updated. For example, if theInterval
is 50 and theSpeed
is 10, then theBall
will move 10 pixels every 50 milliseconds. - OriginAtCenter
- Whether the x- and y-coordinates should represent the center of the
Ball
(true
) or its left and top edges (false
). - PaintColor
- The color of the
Ball
. - Radius
- The distance from the center of the
Ball
to its edge. - Speed
- The speed at which the
Ball
moves. TheBall
moves this many pixels everyInterval
milliseconds ifEnabled
istrue
. - Visible
- Sets whether sprite should be visible.
- X
- The horizontal coordinate of the
Ball
, increasing as theBall
moves right. If the propertyOriginAtCenter
is true, the coordinate is for the center of theBall
; otherwise, it is for the leftmost point of theBall
. - Y
- The vertical coordinate of the
Ball
, increasing as theBall
moves down. If the propertyOriginAtCenter
is true, the coordinate is for the center of theBall
otherwise, it is for the uppermost point of theBall
. - Z
- How the Ball should be layered relative to other Balls and ImageSprites, with higher-numbered layers in front of lower-numbered layers.