Reset Time Problem
Hello there Gamesalad Community!
I have a problem on an app I'm developing and would like to get some of your help.
My game is sort of like the one that is very popular in the AppStore at the moment called Llama or Duck?
Soooooo my problem is in the main gameplay, when the images are randomly switching around every 1 second, if I happen to press a button that summons the next picture it so happens that the timer doesn't 'reset' and the image that comes next doesn't stay on the screen as long as it normally would.
Anybody know how I can reset the timer? If this helps, I have a boolean attribute that triggers whenever you get the name of the animal right with the animal on the image and is untriggered after 0.01 seconds.
Thank you for your time!
I have a problem on an app I'm developing and would like to get some of your help.
My game is sort of like the one that is very popular in the AppStore at the moment called Llama or Duck?
Soooooo my problem is in the main gameplay, when the images are randomly switching around every 1 second, if I happen to press a button that summons the next picture it so happens that the timer doesn't 'reset' and the image that comes next doesn't stay on the screen as long as it normally would.
Anybody know how I can reset the timer? If this helps, I have a boolean attribute that triggers whenever you get the name of the animal right with the animal on the image and is untriggered after 0.01 seconds.
Thank you for your time!
Comments
there are 2 animals, 6 images for each of them(tigers and lions)
rule for the random spawner:
every 1 second
change attribute game.spawner to random(1,12)<------12 images
Tiger button
when touch is pressed and game.spawner is either 1,2,3,4,5 or 6
change attribute trueT to true<----- trueT is the boolean attribute for the tiger button
when trueT is true
destroy either tiger1,2,3,4,5 or 6 and add +1 to game.score
same goes for the lion button and images
If there is anything left you may need please tell me.If you find the problem please tell me too!
What currently is happening is that if you press the button 1 second after the random number is generated, it destroys the tiger (although why not just recycle it by moving it to a new position or giving it a new image?) and chooses a new number immediately. But if you press the button 0.9 seconds after the random number is generated, the timer fires again 0.1 seconds later to choose a new number.
Here's the algorithm I would use:
choose random image
change attribute game.timeStamp (real) to self.Time
If self.TIme>game.timeStamp+1 [this is the every 1 second timer without a timer behavior] OR game.trueT=true:
.....choose random image
.....change attribute game.timeStamp (real) to self.Time
A better way to do this is to import images with their names 1.png, 2.png, 3.png, etc. and then do Change Image to game.spawner or whatever your random number attribute is.
If that still doesn't make sense, just substitute "spawn new tiger button" for "choose random image" in my post above.
choose random image initial image for the actor
change attribute game.timeStamp (real) to self.Time "stamp" the current time
*The two behaviors above are repeated within the rule below... the reason for their appearance above is because we want them to fire immediately rather than after one second has elapsed
If self.TIme>game.timeStamp+1 [this is the every 1 second timer without a timer behavior] OR game.trueT=true: if one second has elapsed since "stamp" or button was pressed
.....choose random image change the image for the actor
.....change attribute game.timeStamp (real) to self.Time "stamp" the current timer