Timer : When user answer right, add 10 seconds.

Timer : When user answer right, add 10 seconds.

How can i implement when user choice the correct answer,
the system increase 10 second ?

gameTimer = timer.performWithDelay(time_remaining ,progressBAR, 1)

[import]uid: 22631 topic_id: 26857 reply_id: 326857[/import]

There isn’t a way to add/subtract time from an active timer, but since you already have your timer assigned to a flag/reference variable (gameTimer), I’d suggest you just cancel the timer, add 10 seconds to the remaining time, and start the timer again with that value.

timer.cancel( gameTimer )  
time\_remaining = time\_remaining + 10000 --10 seconds converted to milliseconds, of course!  
gameTimer = timer.performWithDelay(time\_remaining ,progressBAR, 1)  

Hope that helps!

Brent Sorrentino
Ignis Design [import]uid: 9747 topic_id: 26857 reply_id: 108994[/import]

@ Brent Sorrentino

Thanks so much! [import]uid: 22631 topic_id: 26857 reply_id: 109045[/import]

I would take a slightly different approach. I would have a variable that kept my time left in seconds and fire off a timer that ran for 1000 ms (1 second) and in it’s onComplete, subtract a second from my counter. If > 0 then fire off the 1 second timer again.

That way you have a nice number for display. It’s easy to add or take time away. [import]uid: 19626 topic_id: 26857 reply_id: 109078[/import]