![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Timofey |
I tried to do as they say in other answers, but I can’t do it. in windows open gives “0”, but on android nothing. I also tried to give permission when compiling to apk. in windows this work.
func _notification(what):
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
save_data({score=score})
func _ready():
score = load_data()['score']
func save_data(data: Dictionary) -> void:
var file := File.new()
file.open('user://save.data', File.WRITE)
file.store_var(data)
file.close()
func load_data():
var file := File.new()
if file.file_exists('user://save.data'):
file.open('user://save.data', File.READ)
var data = file.get_var()
file.close()
return data
return