use for loops(the looped variable)

Get help using Construct 2

Post » Wed Jan 08, 2014 4:08 pm

In code I would do:

for(i=0;i<9;i++){

createobject(x=i,y=100)

}

This creates 10 objects with different x based on the var ""i"" of the for loop.

How do I do that in Construct 2?

Thanks.
[size=200]1. Best Construct 2 course :HERE.10$!

2. 155 games source codes for sale on scrira store 12,86$each. PM me if interested to speed up the uploading process.
[/size
B
32
S
8
G
4
Posts: 149
Reputation: 3,715

Post » Wed Jan 08, 2014 4:20 pm

use the 'loopindex' expression


Repeat 10 times > create object at loopindex*10, 100

will create 10 objects with respective x coords of 0,10,20,30 etc

loopindex can be used for any type of loop, not just Repeat

if you're in multiple loops, you can refer to them (provided they are 'for' loops) like this:
loopindex("loopname")
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Wed Jan 08, 2014 4:42 pm

System:For would be the equivalent.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Thu Jan 09, 2014 8:49 pm

Thanks
[size=200]1. Best Construct 2 course :HERE.10$!

2. 155 games source codes for sale on scrira store 12,86$each. PM me if interested to speed up the uploading process.
[/size
B
32
S
8
G
4
Posts: 149
Reputation: 3,715


Return to How do I....?

Who is online

Users browsing this forum: DharmaOne, Google [Bot], Yahoo [Bot] and 8 guests