open SQLite from Godot
This commit is contained in:
parent
1959852747
commit
e406e9e44c
4 changed files with 44 additions and 1 deletions
28
godot/global.gd
Normal file
28
godot/global.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends Node
|
||||
# https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html
|
||||
|
||||
var current_scene = null
|
||||
var db : SQLite = null
|
||||
|
||||
func _ready():
|
||||
var root = get_tree().root
|
||||
current_scene = root.get_child(root.get_child_count() - 1)
|
||||
|
||||
func goto_scene(path):
|
||||
call_deferred("_deferred_goto_scene", path)
|
||||
|
||||
func _deferred_goto_scene(path):
|
||||
# It is now safe to remove the current scene.
|
||||
current_scene.free()
|
||||
|
||||
# Load the new scene.
|
||||
var s = ResourceLoader.load(path)
|
||||
|
||||
# Instance the new scene.
|
||||
current_scene = s.instantiate()
|
||||
|
||||
# Add it to the active scene, as child of root.
|
||||
get_tree().root.add_child(current_scene)
|
||||
|
||||
# Optionally, to make it compatible with the SceneTree.change_scene_to_file() API.
|
||||
get_tree().current_scene = current_scene
|
||||
Loading…
Add table
Add a link
Reference in a new issue