To create a
New. To give a SpriteSurface
ownership of a Sprite, send the SpriteSurface the Attach message,
handing it the Sprite; the SpriteSurface henceforward will draw the
Sprite in accordance with the Sprite’s various properties. For
example, if the Sprite’s X is
0 and its Y is
0, then the Sprite’s image will visibly
appear at the upper left of the SpriteSurface the next time the
SpriteSurface draws a frame. To detach a Sprite from its
SpriteSurface, send the Sprite the Close message.
A Sprite has the following properties:
The Picture displayed as the Sprite image.
The coordinates of the Sprite image’s top left, with respect to the top left of the SpriteSurface that owns it.
A nonnegative integer; the lower the value, the earlier in the redraw process the SpriteSurface will redraw this Sprite. When there are many Sprites, this can help maintain smoothness of animation, because you can make sure that the Sprites redrawn first are the ones the user is paying closest attention to. Or, you can use this property in a different way: a Sprite image drawn later will appear on top of a Sprite image drawn earlier, if their positions coincide.
A Sprite also has a Group property, whose meaning will be made clear in connection with collisions, later in this section.
Sprite images are drawn transparently against the background, in
accordance with the basic rule of Picture transparency, where
rgb(255,255,255) is the transparent color ...