New to me? Loops?

CaptFinnCaptFinn Member Posts: 1,828

Ok I just came across "Loops" in the list of behaviors. What is loops? And give me a example of how loops is used in a game. And what benefits does loops bring to the table?

Finish this sentence:

"Thank goodness we finally have loops, if it werent for loops I wouldnt be able to do , ___________________. Or I would still be having to do ______________________, and thats a lengthy process."

And reading the side note. It sounds like loops has a limitation to what it can do. Long list of behaviors it wont work with.

Comments

  • ArmellineArmelline Member, PRO Posts: 5,415

    When you put logic in a loop, it will run over and over and over again until the condition(s) you give it is met.

    Let's say I want to spawn ducks continuously until there are 100 ducks on the screen. You could use a loop like this:

    What it's saying is that WHILE the number of ducks is less than 100, SPAWN A DUCK then ADD 1 TO TOTAL DUCKS.

  • CaptFinnCaptFinn Member Posts: 1,828

    Ok Ill try that out in my top down shooter game.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I have a video on loops, they have been around for awhile now.

  • IceboxIcebox Member Posts: 1,485

    I still don't know whats the difference between loops and constrains , cause i can loop a change attribute motion linear velocity , instead of constraining motion linear velocity , they are the same right ? But on performance when I tried looping vs constrain , constrain was better regarding fps , I don't understand why though , maybe im using the loop behavior in a wrong way

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited July 2015

    @Icebox1910 said:
    I still don't know whats the difference between loops and constrains , cause i can loop a change attribute motion linear velocity , instead of constraining motion linear velocity , they are the same right ? But on performance when I tried looping vs constrain , constrain was better regarding fps , I don't understand why though , maybe im using the loop behavior in a wrong way

    Loops work differently than constrain if they didn't there would be no need for a loop behavior. loops are a more efficient way of doing particular things, like @Armelline posted. Mostly it has to do with the code scan cycle. Same with Loop over table

    http://forums.gamesalad.com/discussion/68317/loop-behavior-vs-constrain-behavior

  • IceboxIcebox Member Posts: 1,485

    thanks I think I understand , I didnt read the thread before :)

  • CaptFinnCaptFinn Member Posts: 1,828

    can you link your video?

  • MantoManto Member Posts: 796

    @FINNBOGG said:
    can you link your video?

    Probably this one:

  • DreamLabDreamLab Member Posts: 2,127

    Loops provide a way of doing something some variable amount of times, or doing something until some condition is no longer true.

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @DreamLab - Now there's a name I haven't seen in a few years! Good to see you, buddy!

Sign In or Register to comment.