How do I Nest loops

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Thank you sir, this is exactly what I wanted. Is it fair to say that a sub-event can be placed almost anywhere?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)