Trouble having scene controlled by a timer, any advice?
Hi all, Im trying to add in a bonus round for UfoBlaster and have been playing around with a scene that is controlled by a timer of 60 seconds.
The timer starts when game starts and counts down to 0, when at 0, game is then over.
In the scene attributes Ive created a boolean attribute called BonusGameStart and set it to false, then Ive tried 3 different attributes for the BonusTime counter. real, index and integer, which were all set to 60. None of them seem to be working.
Then I have created an actor called bonus1timer and put it onto the scene outside of the viewable area
Below is what I put in the behaviours.
First rule. If game.over = false, change attribute game.BonusGameStart to 1
Second rule. If game.BonusGameStart is true every 1 second, change attribute game.BonusTime to game.BonusTime -1
Third rule. If game.BonusTime = 0, change attribute game.gameOver to 1
Next to see if the timer is counting down, I text area at bottom of screen for displaying the timer which has the behaviours set to
if game.gameover = false, text displays "Timer:"..game.BonusTime
This part displays fine on the screen, but it just shows Timer: 60 and does nothing else.
Outside of that the game doesn't go to game over after 60 seconds, I guess because its not actually counting down.
I've read countless threads on here about doing this, and haven't found one yet that's helped me get it to work. Any suggestions would be greatly appreciated.
Download UfoBlaster on the iTunes store
Best Answer
-
gyroscope I am here.Posts: 6,598
Hi @aussiefaz
what you've written all seems fine so I'm not totally sure what's stopping the timer from working....
One thing I can suggest tho' is to double check that your attribute game.over is actually false, and not been changed to true somewhere else...
Another thing to mention, your attribute BonusGameStart seems superfluous; surely you just need:
Rule: When game.over = false Timer: every 1 second, Change Attribute game.BonusTime to game.BonusTime -1 Rule: When game.BonusTime = 0, change attribute game.gameOver to true
Btw, an integer is fine for your game.BonusTime attribute.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers
Hi @gyroscope that worked beautifully. Ive deleted the BonusGameStart since its not needed.
Ive still got the game.BonusTime attribute set on Real at this stage, and it worked with it like this.
I guess everyone goes through the point with game making where it can do your head in, if it looks like it should work but doesn't
I was probably trying to over complicate it, when now that I've done it this way its rather simple.
BTW the game.over I have set that as soon as scene loads, to false, so was pretty sure that one was safe as it works on my other scenes.
Thanks for your help, now I just have to keep working on my asteroids moving more fluidly, instead of sharply to a new position
Download UfoBlaster on the iTunes store