Book Image

Gamemaker Essentials

4 (1)
Book Image

Gamemaker Essentials

4 (1)

Overview of this book

Table of Contents (16 chapters)

Variables


As in any programming language, the first things you should know is how to initialize different types of variables and how each variable type can be used. In GameMaker, there are four main types of variables: instance, local, global, and arrays.

Instance variables

An instance variable is one that is local to the instance it is initialized in. This means that it is not directly accessible in any other instance within your game and must have the instance ID for it to be referenced from outside of the instance it is created in.

To initialize an instance variable, type its name, the equals sign (=), and then its value. The value can be either a real or a string. If the value is a string, then the text must be enclosed in quotation marks.

The following is a sample of two instance variables being initialized in GameMaker:

Once these variables have been initialized, they can be used in any event of the object.

Local variables

A local variable is a variable that is local to the code block or...