How do I Nest loops

Just started using Construct 2? Post your questions here

Post » Tue Apr 07, 2015 8:34 pm

I am experimenting with laying out a playfield programmatically instead of by hand. I wish to create a nested for loop that allows me to place blocks in a row with an attached scale and transform as they come into the playfield. Here is pseudocode

for x = 0 to 20
Create Instance Of Object and place
scale and rotate instance to larger than view port
for x = 1 to number of steps.
Scale = Scale - (scale/number of steps)
rotate instance 360 as it is coming in
next
play sound "Crash"
next

For the life of me I cant figure out how to nest loops.
B
4
Posts: 3
Reputation: 206

Post » Wed Apr 08, 2015 12:34 am

Use sub-events to nest loops (you can create a sub-event by right-mouse clicking on an event and clicking Add > Subevent). Name each loop and then use the expression "loopindex([loopname])" to get the loop index for a given loop.
Image
B
10
S
3
G
2
Posts: 196
Reputation: 2,053

Post » Wed Apr 08, 2015 4:36 pm

Thank you sir, this is exactly what I wanted. Is it fair to say that a sub-event can be placed almost anywhere?
B
4
Posts: 3
Reputation: 206


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests