Home Game Development How so as to add a timer that retains working even the sport is closed – Cocos Creator

How so as to add a timer that retains working even the sport is closed – Cocos Creator

0
How so as to add a timer that retains working even the sport is closed – Cocos Creator

[ad_1]

I wish to create an power system in my sport the place the participant could have 5 power and can lose 1 every stage performed … and i need the power to regenerate 1 power each 20m.
how am i able to achieve this ? i need the timer to maintain working regardless that the sport is closed.
Ty upfront

1 Like

I feel it’s higher to only use a timestamp with the power object, whenever you launch the sport you possibly can evaluate the final power timestamp with the precise time and calculate the delta, for each 20 minutes you possibly can add yet another power again. When the sport launches it retains your timer logic

2 Likes

@leRenard
The solely drawback right here. is that The participant would possibly cheat by altering the time.
the one answer is to attach the sport to a time server that’s not changable by the participant
(The participant is unable to vary time)

@nutrino
You would possibly do one thing like Shadow combat 2
If you need your sport to works offline
When the the participant’s system related the web calculate the timestamp from the server.
Otherwise from the system’s timer

1 Like

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here