Differences

This shows you the differences between two versions of the page.

Link to this comparison view

gdevelop:documentation:manual:global_variables [2015/05/18 12:28] (current)
Line 1: Line 1:
 +====== Edit initial variables ======
 +
 +You can declare variables and their initial values for any variable type: **global** variables, **scenes** variables or **objects** variables.
 +
 +{{ gdevelop:​documentation:​manual:​variables.png?​nolink |}}
 +
 +Variables can be used in events without declaring them, but declaring variables allows to attribute initial values and declared variables are more efficient than not declared variables when used intensively in events.
 +
 +===== Basic changes =====
 +
 +Use the first button of the toolbar to add a new variable. You can then change its value by double cliking on it.
 +Toolbar can also be used to reorder the variables, delete the selected variable or modify the name of an existing variable.
 +
 +===== Finding undeclared variables =====
 +
 +For scenes and global variables, you can scan the project for undeclared variables using this button:
 +
 +{{ gdevelop:​documentation:​manual:​searchforundeclaredvariables.png?​nolink |}}
 +
 +After clicking on it, GDevelop will scan the project and will present you a list containing the name of variables used in the events but not declared in the list. You can then check in this list the variable you want to be added to the already declared variables.
 +
 +===== Declaring structures =====
 +
 +GDevelop supports the use of **structures**:​ structures are variables that contains other variables, called the **child variables**,​ instead of a single value or text.
 +
 +You can add a child to a variable by making a right click on it, and choosing ''​Add a new child'':​ The variable will be transformed into a structure and the child variable will be added.\\
 +In the events, you can access to a child variable using this syntax: ''​Variable.ChildName''​. You can also enter a text expression instead of the child name using brackets
 +: ''​Variable.["​Child"​+ToString(Variable(Index))]''​
 +
 +You can learn more about structures in [[gdevelop:​tutorials:​howtousevariables|this tutorial]].