Maybe we'll break down the lines and see what's happening: var savenodes = get_tree().get_nodes_in_group("Persist") The code snippet I posted shows the part of the code that's doing that. Your save_game function is calling the save() function on your player. How would I call the save() function in the KinematicBody2D? I've read the Docs many times and they explain it in a way that I can''t really understand. Then when I click on the continue button again I should reload my KinematicBody2D's position right? ( I added a move function so I could see if it would reload it's current pos ) But nothing happens. Then I wanted to make it so I could go back to the menu screen ( Just above ) Get_tree().change_scene("res://Scenes/scene_a.tscn") If (i = "filename" or i = "parent" or i = "posx" or i = "posy"): Get_node(currentline).add_child(newobject) Var newobject = load(currentline).instance() # First we need to create the object and add it to the tree and set its position. Savegame.open("user://savegame.save", File.READ)Ĭurrentline.parse_json(savegame.get_line()) Var currentline = # dict.parse_json() requires a declared dict. If !savegame.file_exists("user://savegame.save"): Savegame.open("user://savegame.save", File.WRITE) Var savenodes = get_tree().get_nodes_in_group("Persist") In scene_b I have a control node with a script, I added a player ( KinematicBody2D) then I followed the Godot docs Saving tutorial, which I then got this code into my Control Node Script this is what the code looked like in the Control Node (Btw there are correct spacing it just didn't load) This made it so when I clicked the ContinueButton it changed to scene_b. Get tree.changescene("res://Scenes/scene_b.tscn") So I created two scenes named scene_a and scene_b Scene_a had a continue button which I just connected to a main scene_a script with just a simple code like this.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |