简体   繁体   中英

libGDX: CountDownTimer still running when a device is off

In my game I want to put daily rewards, So I need the countdown of the Timer still running when the player dispose the game. How can I do that?

You can store a timeStamp in preferences or better protected in a encrypted file. But the user can alter the time on his device and this will break. There are a couple more options.

  • Get a timestamp from a online server . There are several servers available where you can get a timestamp. But if the server closes or is down your game will break.

  • Store everything in a database. In my current project I have buildings that take a long time to build so I store the time the building should finish. When the player logs in it retrieves building information for his account from the database. You have full control over your data this way and most databases can calculate times and dates very well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM