GM: local variable

From GMpedia.org Wiki

Jump to: navigation, search

A local variable in Game Maker is a variable set by a certain object e.g.

my_var = "variable";

Suppose you'd like to use the draw_text function of gm to draw this string on screen. And you'd like to use another object to draw the string.

Then you cannot use this piece of code:

draw_text(x,y,my_var);

You need to indicate of which object this local variable is from. Suppose you've called this object obj_text, then you get:

draw_text(x,y,obj_text.my_var);

So it basically says "draw the value of the variable my_var of object obj_text at position (x,y) in the window".

Note: according to the explanation above, global variables can be seen as local variables assigned to the global object.

Personal tools