开发者

How to calculate time elapsed since an action without the danger of the user changes the time

开发者 https://www.devze.com 2023-04-09 23:02 出处:网络
Hi i am developing an application and i want the user to be able to kill an enemy again after 12 hours have passed. How can i do this to avoid the possi开发者_如何学Cbility of the user changing the ti

Hi i am developing an application and i want the user to be able to kill an enemy again after 12 hours have passed. How can i do this to avoid the possi开发者_如何学Cbility of the user changing the time in his phone and enabling again the option to kill an enemy?


Use a sticky service. Every time you kill an enemy, run a CountdownTimer.

However I think this is overkill, If it is a simple game that you are making, you should store the elapsed time since boot. Then regenerate the enemy if the time difference is > 12 hours.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号