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
34
S
8
G
4
Posts: 157
Reputation: 3,781

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
22
G
248
Posts: 3,758
Reputation: 138,067

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
34
S
8
G
4
Posts: 157
Reputation: 3,781


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests