Here is a basic loop structure:
- Code: Select all
int i;
for(i=0; i<10; i++)
{
action here;
}
note that int declarations (int i;) must come at the very beginning of the script window.
Now if our action is:
CreateActor('block", "block1", "no parent", "no path", i*50, 0, true);
then the loop will run till its finished (i<10; so when i reaches 10, the loop stops).
And create an actor every 50 pixels.(50*i)
You can avoid having lots of clones in your editor mode by creating clones in game using loops.
Likewise, it makes sorting things much easier;
- Code: Select all
int i;
for(i=0; i<10; i++)
{
if(blockcolor[i]>0){
do this;
}
}
This loop will check for any values in the array blockcolor[] and then you can use the output as you see fit.
You can also run that same loop, with the action
blockcolor[i]=0; and reset every cell in the array to 0.
Loops help you create, edit, and manage large groups of clones with ease.
Best of luck to you!