Trying to make a cool down for a button

So I am making a game and I need to have a button that uses a bomb have a cool down so that you don't spam it. What I have is a rule when all conditions are valid: actor received event, touch is pressed and attribute self.on is true spawn actor, bomb in front of actor... in the same rule I have change attribute self.on to (i don't know how to make it say something like self.on false.

then I have another rule that says when attribute self.on is false, after 1 second (run to completion is checked) change attribute self.On to (need to know how to make it say something like self.On true.

thanks guys

Comments

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

    You can do this without a boolean by using a "time stamp."

    When touch is pressed and game.Time > game.lastSpawnTime + 1
    ..... Spawn actor, change attribute game.lastSpawnTime to game.Time.

    Adding one makes the delay one second. If you wanted a 5-second delay you would add 5 to game.lastSpawnTime.

    Make sure to set the rule condition to ALL instead of ANY.

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

Sign In or Register to comment.