Loops

Get help using Construct 2

Post » Wed Apr 11, 2012 7:46 pm

Hi i'm sorry i'm sure this has an answer in here somewhere but i can't find it. So I used to use VB and when you call a loop e.g.

For Count = 1 to 10
Print(Count)
Next

That would print 1 to 10, my question is how do I call on the value of the loop (as in what number the loop is)

What i am trying to do is lay out a grid of objects according to X and Y values set in an array

I've got as far as 'For "Setup" from 1 to Board.Width' Then i create the object but when i try to set a position i'm wanting to set it as so

1st object (X = (1,1) in the array) (Y = (1, 2) in the array
2nd object (X = (2,1) and Y = 2,2

So in VB i would simply put

X = (Setup , 1) Y = (Setup, 2)

and that would go through the array along the X axis setting the two values

So in basic English I want:

For Setup = 1 to array.width

   Create object on layer 1 at (X = Setup, 1) (Y = Setup, 2)

Next

I hope that made sense
B
4
Posts: 10
Reputation: 600

Post » Wed Apr 11, 2012 8:13 pm

There is a system expression called loopindex, take a look:

http://www.scirra.com/manual/126/system-expressions
B
28
S
9
G
6
Posts: 30
Reputation: 6,609

Post » Wed Apr 11, 2012 8:38 pm

Last edited by Yann on Sun Sep 14, 2014 9:16 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Apr 11, 2012 10:04 pm

Hi Thanks that was exactly what i wanted!

btw loving Construct and that beginners tutorial was amazing



B
4
Posts: 10
Reputation: 600


Return to How do I....?

Who is online

Users browsing this forum: Mallets, zenox98 and 29 guests