Hi there, nooby question lol.
I’m writing a timer that counts down from X minutes.
Countdown function:
private void UpdateTime()
{
secondTillRefill -= Time.deltaTime;
if (secondTillRefill <= 0)
{
currentLives++;
secondTillRefill = interval.TotalSeconds;
}
}
Save the time the application exits - The game is for WP8 - does this work for that?
private void OnApplicationQuit()
{
PlayerPrefs.SetString("TimeOnExit", DateTime.Now.ToShortTimeString());
}
So when I resume I’m currently doing this in Awake:
if (PlayerPrefs.HasKey("TimeOnExit"))
{
var x = DateTime.Now - DateTime.Parse(PlayerPrefs.GetString("TimeOnExit"));
secondTillRefill = x.TotalSeconds;
PlayerPrefs.DeleteKey("TimeOnExit");
}
And it doesn’t work, hence the question xD.
So yeah say I exit the game and the timer is on 1:30 (1 minute, 30 seconds)
I restart the game 30 seconds later, the timer should show 1:00 (1 minute, 0 seconds).
Anyone point out the flaw?
Cheers