GM: Global variables

From GMpedia.org Wiki

Jump to: navigation, search

A global variable in Game Maker is a variable that doesn't concern any particular object at all. Built-in global variables concern the room settings, such as speed, views, backgrounds, etc.

[edit] Regular Global Variables (Not built in)

If an object that is called o_happy has this piece of code:

{
 global.happy=6;
}

Then any other object could access the same variable "global.happy" and edit it. No object is concerned with it so if o_sad wants to change global.happy to 8 the following piece of code is used:

{
 global.happy=8;
}

Different objects cannot have different global variable values with the same names as global variables concern no object.

[edit] See Also

Personal tools