How do I create object using specific numbers in loop index.

Get help using Construct 2

Post » Mon Jun 27, 2016 5:08 am

I have a function that creates objects by using a loop.

0,0 _ 0,1 _ 0,2 _ 0,3
1,0 _ 1,1 _ 1,2 _ 1,3
2,0 _ 2,1 _ 2,2 _ 2,3
3,0 _ 3,1 _ 3,2 _ 3,3

For "X" from 3 to -1:
For "Y" from 3 to -1:
......................................Create tiles... etc


So now I need it to only render when "X" or "Y" loopindex equals 0 or 3.
In other words I want it to only render on the edges of the made grid and not in the center.

I can't find/think of a way to compare the loopindex of each loop or to insert a variable into it somehow.
B
61
S
34
G
13
Posts: 230
Reputation: 12,271

Post » Mon Jun 27, 2016 5:33 am

For X from 0 to 3
For Y from 0 to 3
x=0
OR
x=3
OR
y=0
OR
y=3
Create tiles

In C2 you add the conditions first, then convert the block to use OR, via the context menu (right-click the left most part of the event and choose "Make 'Or' block").
ImageImageImage
B
71
S
21
G
229
Posts: 3,687
Reputation: 128,338

Post » Mon Jun 27, 2016 6:55 am

Make 'or' Block is what I was needing for the Or statement, I would have had to look that up, Thanks for that solution.

What I meant is how do I compare a loopindex() or how do I use a variable to get a loopindex?
B
61
S
34
G
13
Posts: 230
Reputation: 12,271

Post » Mon Jun 27, 2016 7:10 am

I figured it out. I had "set Variable to Loopindex" in the loop event, but in the loop's sub-event I still had it referencing loopindex instead of the variables, so I was thinking they were being ignored... Opps.... Thanks again for your time.
B
61
S
34
G
13
Posts: 230
Reputation: 12,271

Post » Mon Jun 27, 2016 2:05 pm

You want something similar to this:
Image

http://www.blackhornettechnologies.com/ ... rLoop.capx
ImageImageImage
B
71
S
21
G
229
Posts: 3,687
Reputation: 128,338

Post » Tue Jun 28, 2016 12:29 am

That is what I was asking. I couldn't figure out how to put loopindex into a sub-event, so I ended up making a local variable. I didn't think of adding loopindex into "Compare two values". When I think "Compare two values" I think of Instance, local and global variables. Still learning how flexible Construct 2 is. Thanks again. You're always helpful. :)
B
61
S
34
G
13
Posts: 230
Reputation: 12,271


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests