Hello,
For my first project using Godot i'm trying to reproduce the game 'Jump King'
I created a automated system that work but now i'm trying to make the loading system. By pressing a 'continue' button i read a file that store a position and i apply it on a kinematic body from another scene. The scene seems loading but the player is not moved.
Here's my code for the pressed button (my player has a methods set_saved_position(new_pos): position=new_pos
)
var save_path = 'user://save.dat'
onready var player = get_tree().get_root().get_child(0)
func _on_Continue_pressed():
var data = {}
var file = File.new()
if file.file_exists(save_path):
var error = file.open(save_path, File.READ)
if error == OK:
data = file.get_var()
file.close()
var _y = get_tree().change_scene("res://scene/Level.tscn")
print(data)
player.set_saved_position(data["Pos"])
else:
var _y = get_tree().change_scene("res://scene/Level.tscn")
After testing, i've the good position and i know that the program run the 'if' statement
Thanks you in advance for your help