GM: for
From GMpedia.org Wiki
- This article is about the Game Maker for loop, for the loop in general, see for loop.
The Game Maker for is a type of different loops in Game Maker.
Contents |
[edit] Syntax
Its syntax is as follows:
for(<statement1>;<expression>;<statement2>)
{
<statement3>
}
[edit] Statement1
The first statement is an initialization statement. It initializes the variable that will be evaluated before the execution of each loop. Usually, it is:
i=0
Statement1 is executed only once to initialize the loops.
[edit] Expression
The expression is the condition at which the loop shall stop. When the <expression> is false, the loop stops. It looks like this:
i<=5
The expression is evaluated in the beginning of each loop start.
[edit] Statement2
This statement is executed each time before the loop begins, it should change the value of the variable that has been initialized in statement1. It is usually like this:
i+=1

