timer as a base for an app
Posted: Wed Jan 12, 2022 2:44 pm
hi, i wrote a script of a timer using the if statement like this
but then like this the 'half game changes' and 'last minute changes' don't work (obviously, because if the field "timer" is 10 or 5 it's always greater than 0 so it will run only the first if and never the else if).
so i tried to change it from if to while like this: but the system freezes and it doesn't work, does anyone has an idea on how to make it work? (not necessarily with while or if like i did).
Thanks!
Code: Select all
on ActivateTimer
HideStart
if field "timer" > 0
then
subtract 1 from field "timer"
send ActivateTimer to me in 1 sec
put the result into _pendingMessage
---half game changes---
else if field "timer" = 10 then
show button "doublePoints"
---last minute changes---
else if field "timer" = 5 then
show button "bonus1000"
else
#StopMoveMe
aeStopMoving "all"
#hide button "Stop" with visual effect zoom out very fast
show button "Restart" with visual effect dissolve very fast
show widget "Info"
show widget "Home"
show button "Settings"
GameOver
DisableObjects
HighScore
HideBounuses
end if
end ActivateTimer
so i tried to change it from if to while like this:
Code: Select all
on ActivateTimer
HideStart
#if field "timer" > 0
#then
repeat while field "timer" > 0
subtract 1 from field "timer"
send ActivateTimer to me in 1 sec
put the result into _pendingMessage
end repeat
---half game changes. pls correct the half number if necessary---
if field "timer" = 10 then
show button "doublePoints"
---last minute changes---
else if field "timer" = 5 then
show button "bonus1000"
else
#StopMoveMe
aeStopMoving "all"
#hide button "Stop" with visual effect zoom out very fast
show button "Restart" with visual effect dissolve very fast
show widget "Info"
show widget "Home"
show button "Settings"
GameOver
DisableObjects
HighScore
HideBounuses
end if
end ActivateTimer
Thanks!