Controlling Sprites

This section explains how to configure and control sprites after they've been created and registered.

- Table of Contents -

Setting Sprite Color

You can set the color of a sprite after creating it -- and you're free to change it at any time afterward. To set a sprite's color, use the setSpriteColor function.

- Function Format -
void setSpriteColor (
  int spriteID,
  int red, int green, int blue, int alpha
)

Arguments:

What Is RGBA Format?

RGBA stands for Red, Green, Blue, and Alpha -- the three primary colors of light plus a transparency value.

The alpha value represents the opacity of the color: 0 means fully transparent, and higher values move toward full opacity.

Color blending is done using additive color mixing, which simulates how light behaves -- unlike mixing paints, which uses subtractive blending. For example:

Setting Sprite Depth

Each sprite has a depth value.

When multiple sprites are rendered together, those with higher depth values appear behind those with lower values. To set a sprite's depth, use the "setSpriteDepth" function.

- Function Format -
void setSpriteDepth ( int spriteID, float depth )

Arguments:

This function can be used with rectangle sprites, ellipse sprites, text sprites, and image sprites.

Changing Sprite Size

To change a sprite's drawing size, use the "setSpriteSize" function.

There are two variations depending on the type of sprite.

For Point Sprites:

- Function Format -
void setSpriteLocation ( int spriteID, int x, int y )

Arguments:

For Rectangle, Ellipse, Text, and Image Sprites:

- Function Format -
void setSpriteSize ( int spriteID, int width, int height )

Arguments: