diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-04-18 14:00:15 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-04-18 14:00:15 -0300 |
commit | be46be78012e98d68b960437bf3d33e577948548 (patch) | |
tree | a90870e00664ad963b2c66a704da6bcc3a2bb3d2 /demos/misc | |
parent | 3b434eacde58450965708c3eafb6b22eb2a99361 (diff) |
-renamed function to get object from instance id
-added function to get list of tiles used
Diffstat (limited to 'demos/misc')
-rw-r--r-- | demos/misc/autoload/global.gd | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/demos/misc/autoload/global.gd b/demos/misc/autoload/global.gd index 5d81f9e649..d1bd45461f 100644 --- a/demos/misc/autoload/global.gd +++ b/demos/misc/autoload/global.gd @@ -3,10 +3,25 @@ extends Node var current_scene = null + +func goto_scene(path): + + # This function will usually be called from a signal callback, + # or some other function from the running scene. + # Deleting the current scene at this point might be + # a bad idea, because it may be inside of a callback or function of it. + # The worst case will be a crash or unexpected behavior. + + # The way around this is deferring the load to a later time, when + # it is ensured that no code from the current scene is running: + + call_deferred("_deferred_goto_scene",path) + + func _deferred_goto_scene(path): # Immediately free the current scene, - # there is no risk here. + # there is no risk here. current_scene.free() # Load new scene @@ -18,19 +33,6 @@ func _deferred_goto_scene(path): # Add it to the active scene, as child of root get_tree().get_root().add_child(current_scene) -func goto_scene(path): - - # This function will usually be called from a signal callback, - # or some other function from the running scene. - # Deleting the current scene at this point might be - # a bad idea, because it may be inside of a callback or function of it. - # The worst case will be a crash or unexpected behavior. - - # The way around this is deferring the load to a later time, when - # it is ensured that no code from the current scene is running: - - call_deferred("_deferred_goto_scene",path) - func _ready(): # Get the current scene, the first time. |