Singletons tutorial has deprecated methods. (#6018)

* Singletons tutorial has deprecated methods.
This commit is contained in:
Pixelatex
2022-08-05 19:54:38 +02:00
committed by Hugo Locurcio
parent a780e34117
commit 4019a29546

View File

@@ -146,7 +146,7 @@ means that the last child of root is always the loaded scene.
var current_scene = null var current_scene = null
func _ready(): func _ready():
var root = get_tree().get_root() var root = get_tree().root
current_scene = root.get_child(root.get_child_count() - 1) current_scene = root.get_child(root.get_child_count() - 1)
.. code-tab:: csharp .. code-tab:: csharp
@@ -160,7 +160,7 @@ means that the last child of root is always the loaded scene.
public override void _Ready() public override void _Ready()
{ {
Viewport root = GetTree().GetRoot(); Viewport root = GetTree().Root;
CurrentScene = root.GetChild(root.GetChildCount() - 1); CurrentScene = root.GetChild(root.GetChildCount() - 1);
} }
} }
@@ -195,10 +195,10 @@ current scene and replace it with the requested one.
current_scene = s.instance() current_scene = s.instance()
# Add it to the active scene, as child of root. # Add it to the active scene, as child of root.
get_tree().get_root().add_child(current_scene) get_tree().root.add_child(current_scene)
# Optionally, to make it compatible with the SceneTree.change_scene() API. # Optionally, to make it compatible with the SceneTree.change_scene() API.
get_tree().set_current_scene(current_scene) get_tree().current_scene = current_scene
.. code-tab:: csharp .. code-tab:: csharp
@@ -228,10 +228,10 @@ current scene and replace it with the requested one.
CurrentScene = nextScene.Instance(); CurrentScene = nextScene.Instance();
// Add it to the active scene, as child of root. // Add it to the active scene, as child of root.
GetTree().GetRoot().AddChild(CurrentScene); GetTree().Root.AddChild(CurrentScene);
// Optionally, to make it compatible with the SceneTree.change_scene() API. // Optionally, to make it compatible with the SceneTree.change_scene() API.
GetTree().SetCurrentScene(CurrentScene); GetTree().CurrentScene = CurrentScene;
} }
Using :ref:`Object.call_deferred() <class_Object_method_call_deferred>`, Using :ref:`Object.call_deferred() <class_Object_method_call_deferred>`,