How do I Stop/break the top loop in a nested loop?

0 favourites
  • 9 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • What is the correct way to stop the first loop when using nested loops?

    I've tried using two stops (in the same event and separated with one in sub event)

    But it always stops the bottom loop and goes through the top loop while finding red.

    Ex. here i would expect it to stop X= 32 Y=0 (first red pixel) but it goes on till the last red pixel.

    c3p file at

    github.com/hcatarrunas/HCG/blob/master/ConstructFiles/CanvasFindPixel.c3p

  • When you use the "stop the Loop" it will stop the loop on that current scope so because the "CheckY" loop is the bottom one is the one that stops.

    To avoid this I like to split them into two nested loops so you can stop them independently. To stop the top "CheckX" loop I use a boolean or variable.

    Here is an example:

    https://www.dropbox.com/s/vlfct3k6wpvaxwi/CanvasFindPixel2.c3p?dl=0

  • When you use the "stop the Loop" it will stop the loop on that current scope so because the "CheckY" loop is the bottom one is the one that stops.

    To avoid this I like to split them into two nested loops so you can stop them independently. To stop the top "CheckX" loop I use a boolean or variable.

    Here is an example:

    https://www.dropbox.com/s/vlfct3k6wpvaxwi/CanvasFindPixel2.c3p?dl=0

    Thanks, it seems a bit convoluted way to stop the top loop, but it does work ok.

    I had seen posts with ashley mentioning to leave the loops on same event for nesting, and another post where dop2000 mentioned two stops would work to stop both loops so i was a bit confused.

    I was trying to detect the red shape dimensions and add a clickable sprite over it, so i'll take the "buggy" behavior like posted below.

  • Like i mentioned on previous post i considered what construct was doing and ended up with this code to detect the four corners of the shape on the Drawingcanvas, resize the sprite and place it over.

    It still feels like a bug not stopping both loops, but i'll take it :p

  • Thanks, it seems a bit convoluted way to stop the top loop, but it does work ok.

    Np

    Once you understand how it works it becomes natural.

    I had seen posts with ashley mentioning to leave the loops on same event for nesting

    My guess is he was referring to when you dont need to stop the Loops accurately in that case you can leave the loops on the same event.

    The loops have been working like this since Construct 2:

    You can run a test on C2 and see that it works the same.

    Here is an example:

    https://www.dropbox.com/s/66670ci76rbaxdz/Stop%20Loop.capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll leave an image of tarek2 answer to stop the loop. (in case the files disappear)

    Leave an Ashley ping in case he has the time to give a thumbs up/down for the practice.

  • I'll leave an image of tarek2 answer to stop the loop. (in case the files disappear)

    Leave an Ashley ping in case he has the time to give a thumbs up/down for the practice.

    Your post comes across as a bit rude and weird!

    You asked how to "Stop the Loop" so Tarek2 showed his way according to how construct works and the construct rules but you dont like it?

    It seems that you already knew how the "stop the loop" works but you were not happy, in that case, why not start the thread tagging Ashley directly and let him know that you weren't happy? instead of asking users? and Also by doing so, you could have the benefit to ask if any upgrades can be made.

    You literary asked the creator of the engine to thumb down his own creation as he is the one that created those rules and restrictions, basically the way it's working, so why anyone will thumb down his own creation?

    As Tarek2 showed you this is coming from Construct2 which was released in 2011 more than a decade.

    As I said your post is weird you could just tag Ashley and ask him if any upgrades can be made, or even better this sounds like a feature request which in that case you should have opened a request on the "Feature request platform".

    If you have a better way to stop the loops instead of complaining why not post yours?

    I have also been using the method that Tarek2 posted and I didn't have any problems as it's the only way to stop loops accurately that I found and that has less confusion.

    You already complained about (dop2000, Tarek2, and Ashley) not sure what are you trying to archive or what direction your thread is going as it's all ober the place and your replays to users trying to help you don't sound very friendly.

    Many times we find things that we dont like on construct so we just open a feature request without making that much drama.

    Here the "stop loop" looks like construct works by "Scopes" so it makes sense that will stop the bottom Loop no matter how many stop loops you add to the same event. It looks like you are confused by it should stop by "loops currently running bottom to top" which is different than Running on this "Scope". As a scope can be just one, not multiple on the same event because that will confuse even more.

  • I guess i can see how you could look at it that way.

    I did leave the print showing the standard way that was recommended and only asked for Ashley approval of the process because i had previously seen doop2000 mention to use two stop loops for something i read like it would answer my question

    construct.net/en/forum/construct-3/how-do-i-8/stop-nested-loops-163291

    I did try that and then posted my question. (i'm guessing he was probably thinking of this approach from Tarek2 using some variable to trigger the second stop loop)

    As someone who has used plenty of other software's at work since 2002, i'm very familiar with general practices that end up becoming standard solutions but aren't actually the expected way to use the software.

    And i just wanted to make sure i ended the post with the best answer for new users that would find it when looking for something similar.

  • I suppose you never help on the forums that's why you feel comfortable calling Ashley to thumb (down/Up). If you, for example, help someone on the "How Do I" section and that user calls for Ashley to thumbs (Down/Up) to your answer I dont think you will be that happy and understanding, and I dont think anyone will be as it's unnecessary to do that. Normally on each thread you will have one or more answers and then you pick up the one you think is the best and use it, but I have never seen anyone calling Ashley to thumbs down the answers. For me looks very disrespectful and rude no matter how much software's you used at work or home, I hope no one follows your way of thinking as soon we will have no one left to help on the forums if they get disrespected like that, users that help are helping and spending the time for free after all.

    By the way, if you read "Tarek2" answer says "I like to do it this way":

    "To avoid this I like to split them into two nested loops so you can stop them independently"

    But it didn't say this is the stander way so not sure what you mean by becoming standards as you are free to use whichever method you like, no one forced it on you, it seems like some kind of debate already happened in your head before this thread was created that we dont know as I'm still trying to understand your thread and your answers, its all kind of weird, Thumb down? Just in case the post gets deleted? As if they committed a crime lol.

    You like your way which pretty sure has its own flaws and he likes his way for X reasons and I like my way and everyone will like his own way, nothing to thumb down here, it is just all by preference. You should saw some gratitude for user that trying to help you instead of calling to thumb down their posts, that’s my two cents.

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