Random intervals?

_Ghost__Ghost_ Member, PRO Posts: 22
edited May 2014 in Working with GS (Mac)

I'm trying to set up random intervals for changing a scene.

The following is what I'm trying to set up:

When button "play again" is pressed either 5-10 times randomly, scene changes to scene "main menu."

So far the way I have it set up is:

Created an index attribute called "PlayCounter."

-- when touch is pressed, change attribute "game.PlayCounter" to "game.PlayCounter" +1.

-- when attribute "game.PlayCounter" = 5; change scene to "main menu"

Obviously this just triggers the change in scene only once (after clicking the "play again" button 5 times) and after that, it doesn't restart and continue.

What I want to do is set up a random interval where the scene changes after pressing the "play again" button any random number of times between 5-10; and I'd like to it to do all the time. After the scene has already changed, I want to be able to go back to the scene where the "play again" button is and I want the interval to start over again, after every scene change.

How can I set up this interval? Let me know if what I'm trying to do, makes sense.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You need an integer attribute called game.playCounterMax that you set to random(5,10) at the start of the scene. You also need to change game.PlayCounter to 0 when the scene starts. Then check for When attribute game.PlayCounter = game.playCounterMax to change the scene.

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

  • _Ghost__Ghost_ Member, PRO Posts: 22

    Hi tatiang,

    Thank you for your advice. I actually got it to work in a different way though.

    I simply set game.PlayCounter = random(5,10) and when changing scene set game.PlayCounter = 0

    This seems to have created the random interval of 5-10 by setting the attribute game.PlayCounter's value to 0 at the start of the scene.

    Thank you for your help :)

Sign In or Register to comment.