(Loop issue) Is there any way to implement loop function?

matt72228matt72228 Member Posts: 4
edited April 2012 in Working with GS (Mac)
As title, I want to use loop function (for, while, do while), but I can't find it in gamesalad.
Any help?

Thanks a lot : )

Best Answer

  • greengluegreenglue Posts: 52
    Accepted Answer
    Hi!
    I am pretty sure you can make a Timer to run every 0 seconds, but NOT till completion. Then in there you can have rules depending if you want it to be a while statement, for, etc... So basically: use timers!
    Hope I helped!
    Michael

Answers

  • youngster9youngster9 Member Posts: 326
    To build a while loop just use a rule for example if you want to program the following Java Statement:

    while(score>250)
    {
    ....
    }

    in GS you would create a rule that says if score variable greater than 250 then do the stuff inside the rule.

    For a for loop use a timer or create a variable that counts up and using multiple rules you can use the same method to build a for loop. There really are no programming limitations in GS.

    youngster9
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited April 2012
    Theres no set loop function in gamesalad, youll have to make that yourself with timers and change attributes.

    For example: for(var a = 0; a < 10; a++)

    Would be this in gamesalad.

    Create a interger attribute called a

    In the actor

    Change attribute a to 0
    Timer every 0.1
    Inside the timer have a rule if attribute a < 10
    then in the timer have a change attribute behavior and change a to a+1

    Hope that helps
  • youngster9youngster9 Member Posts: 326
    @JohnPapiomitis

    Cool you know Java too. People really give GS devs a bad rep because they think we are all too stupid to learn how to code but that is not true :D
  • theCodeMonsterstheCodeMonsters Member Posts: 359
    @JohnPapiomitis

    Cool you know Java too. People really give GS devs a bad rep because they think we are all too stupid to learn how to code but that is not true :D
    Amen, we're just lazy. Besides aren't all Programers? Anyways, you can use a timer set it to iterate at 0. Wrap it in a Rule that has your condition.
  • pinata14pinata14 Member Posts: 150
    @JohnPapiomitis

    Cool you know Java too. People really give GS devs a bad rep because they think we are all too stupid to learn how to code but that is not true :D
    :O i've been wanting to learn javascript for awhile now and i tried studying on my own but its kinda too confusing lol. I only know the very basics haha but i would love to learn more in the future, maybe take some comp sci classes

  • matt72228matt72228 Member Posts: 4
    Maybe this is a good suggestion for gamesalad?

    Thanks a lot : )
  • pinata14pinata14 Member Posts: 150
    yea, loops pretty much are just the rules, and timers can make more advanced loops
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I posted instructions with a screenshot here: http://forums.gamesalad.com/discussion/41887/i-can-make-a-loop-in-the-gs. Maybe a moderator can merge these threads?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.