#FileHelper.gd
class_name FileHelper
# 普通存储
static func save(path,data):
var file = File.new()
file.open(path,File.WRITE)
file.store_string(var2str(data))
file.close()
# 普通读取
static func read(path):
var file = File.new()
file.open(path,File.READ)
var data = str2var(file.get_as_text())
file.close()
return data
# 加密存储
static func save_encrypted(path,data,key):
var file = File.new()
file.open_encrypted_with_pass(path,File.WRITE,key)
file.store_string(var2str(data))
file.close()
# 加密读取
static func read_encrypted(path,key):
var file = File.new()
file.open_encrypted_with_pass(path,File.READ,key)
var data = str2var(file.get_as_text())
file.close()
return data
[手把手带你Godot游戏开发]FlappyBird:7 要做到心里有数(计分系统的实现)(未完)
猜你喜欢
转载自blog.csdn.net/hello_tute/article/details/105103786
今日推荐
周排行