Sprite Data Type

Sprites are images that may be moved around independently of what's on the screen; they appear to float in front of whatever has been drawn using other graphic functions.

A sprite is created by converting an image to a sprite using the toSprite function.

In order for the sprite to be shown, it must be made visible using the spriteVisible function and moved to a location on screen using spriteMove. The location of a sprite may be queried using the spriteX and spriteY functions, and it's size may be queried using width and height.

If multiple sprites are present, you may control which are in front of which by adjusting a depth property using the spriteDepth function. By default, the depth is zero (0), which is closer to the viewer. Setting the depth to higher numbers moves the sprite closer to the background. Sprites with lower depth numbers will appear to pass in front of sprites with higher depth numbers.

You may check for collision between any two sprites using the spriteCollision function. A sprite must be visible in order be able to collide.