Global Variables

Application wide

Global Variables are project wide where you can store temporal and non-temporal values which can be changed in runtime. For example, if you allow users to pick the name of their characters, you can store the name they picked for their character in a String Global Variable.

Creating and Editing

To create and edit global variables open the Preferences Menu [⌘+P] and select the Variables option.

(Global Variables editor)

To create a new global variable type in the name and press return or click on the + button. You'll create a variable of type null, which means it holds no value.

Choose which type of value a variable will hold. You can then initialize its default value.

Saving Variables

Some variable types (strings, numbers, booleans, Colors, ...) can be saved between game sessions. This allows the player to pick up the game where they left when closing the application.

To save a variable between sessions, mark the little checkbox next to its name. The header of the variable then will inform you that this variable is savable.

Tags

A game can end up with thousands of global variables. Game Creator doesn't put any limit to the amount of variables you can create, but searching through them can become quite a daunting task. That's why we implemented a feature called Tags.

Tags allow you to categorize global variables in groups. To create a tag click on Edit Tags and type in the name of your tag. For example: Potions. You can also choose the tag's color.

(Click this image to enlarge it)

Out of curiosity, tag color codes have been selected from an open source initiative called Open Colors, which have researched which palettes work well for UI elements.

To categorize a variable with a tag, simply open it and tick the tags you want to include. A variable can have as many categories as you like.

A variable's tag name will be represented with the name and a background color next to it.

Advanced

If you are a programmer and want to access the Global Variables API, check out the scripting guide documentation.

Last updated

Was this helpful?