Wednesday, October 5, 2022
HomeGame DevelopmentEasy methods to add a timer that retains working even the sport...

Easy methods to add a timer that retains working even the sport is closed – Cocos Creator


I need to create an vitality system in my recreation the place the participant may have 5 vitality and can lose 1 every degree 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 though the sport is closed.
Ty prematurely




1 Like

I feel it’s higher to only use a timestamp with the vitality object, once 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



2 Likes

@leRenard
The one drawback right here. is that The participant may 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 alter time)

@nutrino
You may do one thing like Shadow struggle 2
If you need your recreation to works offline
When the the participant’s gadget linked the web calculate the timestamp from the server.
In any other case from the gadget’s timer



1 Like

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments