A ball component is a particular kind of sprite (animated object) that looks like a ball.
A ball is a round sprite that is contained by a canvas, can react to touches and drags, interact with other sprites (image sprites and other balls) and the edge of the canvas, and move according to its properties. For example, to have a ball move 4 pixels toward the top of a canvas every 500 milliseconds (half second), you can set the Speed
property to 4, the Interval
property to 500, the Heading
property to 90 (degrees), and the Enabled
property to True. You can change these and other properties to modify the ball's behavior.
The difference between a ball and an image sprite is that the latter can get its appearance from an image, while a ball's appearance can only be changed by varying its PaintColor
and Radius
properties.
Enabled
Heading
Returns the sprite'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 sprite's position is updated. For example, if the interval is 50 and the speed is 10, then the sprite will move 10 pixels every 50 milliseconds.
PaintColor
Radius
Speed
The speed at which the sprite moves. The sprite moves this many pixels every interval.
Visible
True if the sprite is visible.
X
The horizontal coordinate of the left edge of the sprite, increasing as the sprite moves to the right.
Y
The vertical coordinate of the top of the sprite, increasing as the sprite moves down.
Z
How the sprite should be layered relative to other sprits, with higher-numbered layers in front of lower-numbered layers.
CollidedWith(component other)
Dragged(number startX, number startY, number prevX, number prevY, number currentX, number currentY)
EdgeReached(number edge)
edge
argument tells which edge (or corner) was reached, encoded as follows:
Flung(number x, number y, number speed, number heading, number xvel, number yvel)
NoLongerCollidingWith(component other)
TouchDown(number x, number y)
TouchUp(number x, number y)
Touched(number x, number y)
Bounce(number edge)
Makes this sprite bounce, as if off a wall. For normal bouncing, the edge argument should be the one returned by EdgeReached.
boolean CollidingWith(component other)
MoveIntoBounds()
MoveTo(number x, number y)
Moves the sprite so that its left top corner is at the specfied x and y coordinates.
PointInDirection(number x, number y)
Turns the sprite to point towards the point with coordinates as (x, y).
PointTowards(component sprite)
Turns the sprite to point towards a designated target sprite. The new heading will be parallel to the line joining the centerpoints of the two sprites.
An image sprite component is an animated object that can interact with a canvas, balls, and other image sprites.
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.
Enabled
Heading
Returns the sprite'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
Interval
The interval in milliseconds at which the sprite's position is updated. For example, if the interval is 50 and the speed is 10, then the sprite will move 10 pixels every 50 milliseconds.
Picture
Rotates
Speed
The speed at which the sprite moves. The sprite moves this many pixels every interval.
Visible
True if the sprite is visible.
Width
X
The horizontal coordinate of the left edge of the sprite, increasing as the sprite moves to the right.
Y
The vertical coordinate of the top of the sprite, increasing as the sprite moves down.
Z
How the sprite should be layered relative to other sprits, with higher-numbered layers in front of lower-numbered layers.
CollidedWith(component other)
Dragged(number startX, number startY, number prevX, number prevY, number currentX, number currentY)
EdgeReached(number edge)
edge
argument tells which edge (or corner) was reached, encoded as follows:
Flung(number x, number y, number speed, number heading, number xvel, number yvel)
NoLongerCollidingWith(component other)
TouchDown(number x, number y)
TouchUp(number x, number y)
Touched(number x, number y)
Bounce(number edge)
Makes this sprite bounce, as if off a wall. For normal bouncing, the edge argument should be the one returned by EdgeReached.
boolean CollidingWith(component other)
MoveIntoBounds()
MoveTo(number x, number y)
Moves the sprite so that its left top corner is at the specfied x and y coordinates.
PointInDirection(number x, number y)
Turns the sprite to point towards the point with coordinates as (x, y).
PointTowards(component sprite)
Turns the sprite to point towards a designated target sprite. The new heading will be parallel to the line joining the centerpoints of the two sprites.