summaryrefslogtreecommitdiff
path: root/demos/misc
diff options
context:
space:
mode:
Diffstat (limited to 'demos/misc')
-rw-r--r--demos/misc/autoload/engine.cfg8
-rw-r--r--demos/misc/autoload/global.gd23
-rw-r--r--demos/misc/autoload/scene_a.gd17
-rw-r--r--demos/misc/autoload/scene_a.scnbin0 -> 1459 bytes
-rw-r--r--demos/misc/autoload/scene_b.gd17
-rw-r--r--demos/misc/autoload/scene_b.scnbin0 -> 1448 bytes
-rw-r--r--demos/misc/pause/engine.cfg5
-rw-r--r--demos/misc/pause/icon.pngbin0 -> 5236 bytes
-rw-r--r--demos/misc/pause/spinpause.gd15
-rw-r--r--demos/misc/pause/spinpause.scnbin0 -> 3331 bytes
-rw-r--r--demos/misc/threads/engine.cfg4
-rw-r--r--demos/misc/threads/mona.pngbin0 -> 98894 bytes
-rw-r--r--demos/misc/threads/thread.gd31
-rw-r--r--demos/misc/threads/thread.scnbin0 -> 1638 bytes
14 files changed, 120 insertions, 0 deletions
diff --git a/demos/misc/autoload/engine.cfg b/demos/misc/autoload/engine.cfg
new file mode 100644
index 0000000000..c6ad023013
--- /dev/null
+++ b/demos/misc/autoload/engine.cfg
@@ -0,0 +1,8 @@
+[application]
+
+name="Autoload (Singletons)"
+main_scene="res://scene_a.scn"
+
+[autoload]
+
+global="res://global.gd"
diff --git a/demos/misc/autoload/global.gd b/demos/misc/autoload/global.gd
new file mode 100644
index 0000000000..d9fa308a2f
--- /dev/null
+++ b/demos/misc/autoload/global.gd
@@ -0,0 +1,23 @@
+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
+ get_scene().get_root().add_child(current_scene)
+
+
+func _ready():
+ # get the current scene
+ # it is always the last child of root,
+ # after the autoloaded nodes
+ var root = get_scene().get_root()
+ current_scene = root.get_child( root.get_child_count() -1 )
diff --git a/demos/misc/autoload/scene_a.gd b/demos/misc/autoload/scene_a.gd
new file mode 100644
index 0000000000..21a6a84eb9
--- /dev/null
+++ b/demos/misc/autoload/scene_a.gd
@@ -0,0 +1,17 @@
+
+extends Panel
+
+# member variables here, example:
+# var a=2
+# var b="textvar"
+
+func _ready():
+ # Initalization here
+ pass
+
+
+
+
+func _on_goto_scene_pressed():
+ get_node("/root/global").goto_scene("res://scene_b.scn")
+ pass # replace with function body
diff --git a/demos/misc/autoload/scene_a.scn b/demos/misc/autoload/scene_a.scn
new file mode 100644
index 0000000000..61727a57ba
--- /dev/null
+++ b/demos/misc/autoload/scene_a.scn
Binary files differ
diff --git a/demos/misc/autoload/scene_b.gd b/demos/misc/autoload/scene_b.gd
new file mode 100644
index 0000000000..4a88fddda9
--- /dev/null
+++ b/demos/misc/autoload/scene_b.gd
@@ -0,0 +1,17 @@
+
+extends Panel
+
+# member variables here, example:
+# var a=2
+# var b="textvar"
+
+func _ready():
+ # Initalization here
+ pass
+
+
+
+
+func _on_goto_scene_pressed():
+ get_node("/root/global").goto_scene("res://scene_a.scn")
+ pass # replace with function body
diff --git a/demos/misc/autoload/scene_b.scn b/demos/misc/autoload/scene_b.scn
new file mode 100644
index 0000000000..ae09eeff88
--- /dev/null
+++ b/demos/misc/autoload/scene_b.scn
Binary files differ
diff --git a/demos/misc/pause/engine.cfg b/demos/misc/pause/engine.cfg
new file mode 100644
index 0000000000..a5cb20cc7f
--- /dev/null
+++ b/demos/misc/pause/engine.cfg
@@ -0,0 +1,5 @@
+[application]
+
+name="Pause"
+main_scene="res://spinpause.scn"
+icon="res://icon.png"
diff --git a/demos/misc/pause/icon.png b/demos/misc/pause/icon.png
new file mode 100644
index 0000000000..49b3fd4053
--- /dev/null
+++ b/demos/misc/pause/icon.png
Binary files differ
diff --git a/demos/misc/pause/spinpause.gd b/demos/misc/pause/spinpause.gd
new file mode 100644
index 0000000000..c21c13b4e1
--- /dev/null
+++ b/demos/misc/pause/spinpause.gd
@@ -0,0 +1,15 @@
+
+extends Spatial
+
+
+func _on_pause_pressed():
+ get_node("pause_popup").set_exclusive(true)
+ get_node("pause_popup").popup()
+ get_scene().set_pause(true)
+
+
+func _on_unpause_pressed():
+ get_node("pause_popup").hide()
+ get_scene().set_pause(false)
+
+
diff --git a/demos/misc/pause/spinpause.scn b/demos/misc/pause/spinpause.scn
new file mode 100644
index 0000000000..a3835c4374
--- /dev/null
+++ b/demos/misc/pause/spinpause.scn
Binary files differ
diff --git a/demos/misc/threads/engine.cfg b/demos/misc/threads/engine.cfg
new file mode 100644
index 0000000000..6f19936c9d
--- /dev/null
+++ b/demos/misc/threads/engine.cfg
@@ -0,0 +1,4 @@
+[application]
+
+name="Loading in a Thread"
+main_scene="res://thread.scn"
diff --git a/demos/misc/threads/mona.png b/demos/misc/threads/mona.png
new file mode 100644
index 0000000000..0bcda570b4
--- /dev/null
+++ b/demos/misc/threads/mona.png
Binary files differ
diff --git a/demos/misc/threads/thread.gd b/demos/misc/threads/thread.gd
new file mode 100644
index 0000000000..7d8aabd1b7
--- /dev/null
+++ b/demos/misc/threads/thread.gd
@@ -0,0 +1,31 @@
+
+extends Node2D
+
+# member variables here, example:
+# var a=2
+# var b="textvar"
+
+var thread = Thread.new()
+
+#this function runs in a thread!
+#threads always take one userdata argument
+func _bg_load(path):
+ print("THREAD FUNC!")
+ #load the resource
+ var tex = ResourceLoader.load(path)
+ #call _bg_load_done on main thread
+ call_deferred("_bg_load_done")
+ return tex #return it
+
+func _bg_load_done():
+ #wait for the thread to complete, get the returned value
+ var tex = thread.wait_to_finish()
+ #set to the sprite
+ get_node("sprite").set_texture(tex)
+
+func _on_load_pressed():
+ if (thread.is_active()):
+ #already working
+ return
+ print("START THREAD!")
+ thread.start(self,"_bg_load","res://mona.png")
diff --git a/demos/misc/threads/thread.scn b/demos/misc/threads/thread.scn
new file mode 100644
index 0000000000..349127529a
--- /dev/null
+++ b/demos/misc/threads/thread.scn
Binary files differ