Book Image

Gamemaker Essentials

4 (1)
Book Image

Gamemaker Essentials

4 (1)

Overview of this book

Table of Contents (16 chapters)

Depth


While working with objects in GameMaker, you may run into a few issues when it comes to one object going behind or in front of another. This is an issue caused by something called depth.

Depth in GameMaker is used to order objects from lowest to highest in a room. It can be seen much the same as a layer in an image editor such as Photoshop. By default, an object's depth is set to 0. If more than one object has the same depth value, then they will be ordered first to last, based on the order you create them in the room.

The higher an object's depth is, the lower it is drawn in a game room. So if an object with a depth value of one overlaps an object with a depth value of zero, then the object with the depth value of zero will appear on top of the object with a depth value of one.

Depth ordering

An object with a depth that is higher than another, will execute its code first. Oftentimes, this greatly affects the creation of objects in a room. For example, a button may need to appear on top...