sprite (Game Maker)

A sprite is an image, or a number of images, that represents something in the game. If a sprite is not animated (a tree in an RPG for example), it only has one image. If it is animated, the sprite has a number of subimages.

Many games use multiple sprites with different animations each to represent one character performing different actions such as walking, jumping and falling. The sprite displayed by the object can be changed by changing the image_index of the object.

Naming Conventions

Sprites are usually prefixed with spr to distinguish them from the object that they represent. Examples :

  • spr_player
  • sprPlayer

Sprite Transparency

Sprites in Game Maker use the color of the lower, left pixel to determine the transparent color of the entire sprite. Whatever this color is, the same color will be transparent in the entire sprite. Future versions were said not use the "left pixel transparency", however, we haven't had a chance to see if this is included in Game Maker 7.

If you absolutely need the bottom / left pixel not to be transparent, you can make an extra line of pixels at the bottom of your sprite. If you need to set your sprite origin at any place other than the top, left corner, remember to account for the added line of pixels.

Sprite Origin

The sprite origin corresponds to its position in a room.

Depth and Drawing Order

Depending on the depth of the instance, it will be drawn in front of or behind other instances. Instances with higher depth will be drawn first, instances with lower depths are drawn last, thus, those with higher depths appear behind instances with lower depths.

Subimages

A sprite can be a single image, or a series of images that animate. Each of these images are numbered starting at 0. You can access and change the currently displayed subimage by the variable image_index

Related Pages

Variables

FAQs

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.