1

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?

iibrahimbakr
  • 1,116
  • 1
  • 13
  • 32
  • 1
    you cant. simply store a timestamp and when he gets back calculate the time difference. This even works when the game is not running in any way – bemeyer Dec 27 '15 at 13:46
  • 1
    Thanks, for replying on my question. you're alright for this trick solution. – iibrahimbakr Dec 28 '15 at 13:20

1 Answers1

1

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.

Community
  • 1
  • 1
Madmenyo
  • 8,389
  • 7
  • 52
  • 99