0 votes

I'm working on a small game where time should continue to pass at least half speed when the game is closed. How should I go about this? Like, how would I save the current time and compare it next time it's open?

in Engine by (616 points)

1 Answer

0 votes
Best answer

Use OS.get_datetime() to get the time and save it to a file when you quit the game. When you open the game, load the file and use OS.get_datetime() again. Then compare the two results to get the variation of time.

More info: OS.get_datetime(), File class

by (247 points)
selected by

How would I do that when an Android game is closed or switched from?

I'm sorry, but I'm not familiar with mobile development yet. I just assumed that you had some kind of button to handle quitting and one to load. Have you tried Handling quit requests?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.