Hi
I cant figure out how to save Minutes:Seconds:Fractions as one in PlayerPrefs instead of saving them separately.
Heres the problem, now i have it like this :
PlayerPrefs.SetInt("Level_" + nowLevel + "_minutes", minutes);
PlayerPrefs.SetInt("Level_" + nowLevel + "_seconds", seconds);
PlayerPrefs.SetInt("Level_" + nowLevel + "_fractions", fractions);
But i want to save it as this :
PlayerPrefs.SetInt("Level_" + nowLevel + "_time", minutes:seconds:fractions);
Does anyone know how i could do that ?
Convert it to/from a single number (the total in terms of the fraction) using simple math. e.g., 19231 = 3 minutes, 12 seconds, and 31 hundredths. (minutes*60 + seconds) * 100 + fraction
–Eric
Eric5h5:
Convert it to/from a single number (the total in terms of the fraction) using simple math. e.g., 19231 = 3 minutes, 12 seconds, and 31 hundredths. (minutes*60 + seconds) * 100 + fraction
–Eric
Thanks Eric, but now im wondering how to convert it back.
timeFull = (minutes*60 + seconds) * 100 + fractions;
timeMins = timeFull / 60;
timeSecs = timeFull % seconds;
timeFrac = (timeFull * 100) % 100;
print(timeMins + ":" + timeSecs + ":" + timeFrac);
Doesn’t seem to be working (im bad at math).
var total = 19231;
var minutesSeconds = total/100;
var fractions = total%100;
var minutes = minutesSeconds/60;
var seconds = minutesSeconds%60;
–Eric