[quote=“doubleslashdesign,post:17,topic:327690”]
@lgalcott
Ok so as I understand it what you are trying to do is this
User has 5 lives.
Life 1, Life 2, Life 3, Life 4 , Life 5
So if a user looses a life and now has 4 lives a counter starts counting down from say ( 3 min = 180 seconds ).
now during this count down the users looses life 4 and now has 3 lives left.
When Life 5 is lost a counter should start a 180 second count down to replace this lost life.
When Life 4 is lost a counter should start a 180 second count down to replace this lost life.
So from as I understand it you could have 2 timers going at one time to replace the lost lives.
So timer 5 - counting down could be at 30 seconds to replace life 5.
Then life 4 is lost and now it starts a counter at 180 to replace life 4 - so we now only have 3 lives.
when timer for Life 5 reaches down to zero then you now have 4 lives again
when timer for Life 4 ( from above ) reaches zero you now have 5 lives again.
is this correct? is this what you are trying to do?
If so doing the calculations your self will be a massive headache, and very buggy.
There are a couple ways you can do this, but the easiest I can think of is to use the timer.performWithDelay() to update a lost life with something like this.
Some code some how executes RemoveUsersLife local function RemoveUsersLife() local function RestoreUsersLife( event ) print( "listener called" ) end int\_UsersLives = int\_UsersLives -1 -- remove one of the users lives if UsersLives \< 1 then CallGameOverLogic(); else ---Start Timer to restore users life timer.performWithDelay( 180000, RestoreUsersLife) -- 1000 milliseconds = 1 second (180,000 = 3 min) I think end end ---
If you need to have a countdown shown on the screen at the same time, then I need to think about how to track multiple of those to display.
Good luck
Larry [/quote]
I think this is a nice approach, however don’t forget about the potential of the game being suspended for an unknown amount of time, in which case, these timers would not be running.
So your still going to have to factor in the time between when the app was suspended and the time it was resumed at.
Cheers