2014-02-10 02:10:30 +01:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
|
|
|
|
var current_scene = null
|
|
|
|
|
|
|
|
|
|
|
|
func goto_scene(scene):
|
|
|
|
#load new scene
|
|
|
|
var s = ResourceLoader.load(scene)
|
|
|
|
#queue erasing old (don't use free because that scene is calling this method)
|
|
|
|
current_scene.queue_free()
|
|
|
|
#instance the new scene
|
|
|
|
current_scene = s.instance()
|
|
|
|
#add it to the active scene, as child of root
|
2014-11-06 01:20:42 +01:00
|
|
|
get_tree().get_root().add_child(current_scene)
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
# get the current scene
|
|
|
|
# it is always the last child of root,
|
|
|
|
# after the autoloaded nodes
|
2014-11-06 01:20:42 +01:00
|
|
|
var root = get_tree().get_root()
|
2014-02-10 02:10:30 +01:00
|
|
|
current_scene = root.get_child( root.get_child_count() -1 )
|