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 vitality system in my sport the place the participant can have 5 vitality and can lose 1 every stage performed … and i would like the vitality to regenerate 1 vitality each 20m.
how am i able to accomplish that ? i would like the timer to maintain working regardless that the sport is closed.
Ty prematurely

1 Like

I believe it’s higher to only use a timestamp with the vitality object, while you launch the sport you may examine the final vitality timestamp with the precise time and calculate the delta, for each 20 minutes you may add yet one more vitality again. When the sport launches it retains your timer logic

3 Likes

@leRenard
The solely drawback right here. is that The participant would possibly cheat by altering the time.
the one resolution 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 struggle 2
If you need your sport to works offline
When the the participant’s machine related the web calculate the timestamp from the server.
Otherwise from the machine’s timer

2 Likes

Ty each very a lot ! I’ll strive to do this.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here