To create global variables, that are visible to all object instances, precede them with the word global and a dot. So for example you can write:
{ if (global.doit) { // do something global.doit = false; } }
Alternatively you can declare the variables as being global. This declaration looks as follows.
globalvar <varname1>,<varname2>,<varname3>, ... ;
Once this declaration has been executed, the variable is always treated as global without the need to put the word global and a dot in front of it. It only needs to be declared once in a piece of code that is executed. After that in all other places the variable is considered as being global.
Sometimes you want variables only within the current piece of code or script. In this way you avoid wasting memory and you are sure there is no naming conflict. It is also faster than using global variables. To achieve this you must declare the variables at the beginning of the piece of code using the keyword var. This declaration looks as follows.
var <varname1>,<varname2>,<varname3>, ... ;
For example, you can write:
{ var xx,yy; xx = x+10; yy = y+10; instance_create(xx,yy,ball); }
Converted from CHM to HTML with chm2web Pro 2.85 (unicode) |