aboutsummaryrefslogtreecommitdiff
path: root/demos/misc/threads
diff options
context:
space:
mode:
authorRémi Verschelde2015-12-09 08:38:23 +0100
committerRémi Verschelde2015-12-09 08:38:23 +0100
commit8639cecf4cedd56452b47503be19c44b304cd02f (patch)
treee2a795da15e40c7d9d5b82e33378f8dbf0eaf67a /demos/misc/threads
parentefbb834936fdc9da9789ad37c9cc61e0b90cda95 (diff)
downloadgodot-8639cecf4cedd56452b47503be19c44b304cd02f.tar.gz
godot-8639cecf4cedd56452b47503be19c44b304cd02f.tar.zst
godot-8639cecf4cedd56452b47503be19c44b304cd02f.zip
Diffstat (limited to 'demos/misc/threads')
-rw-r--r--demos/misc/threads/thread.gd26
-rw-r--r--demos/misc/threads/thread.scnbin1638 -> 1586 bytes
2 files changed, 13 insertions, 13 deletions
diff --git a/demos/misc/threads/thread.gd b/demos/misc/threads/thread.gd
index 7d8aabd1b..fbfd68af2 100644
--- a/demos/misc/threads/thread.gd
+++ b/demos/misc/threads/thread.gd
@@ -1,31 +1,31 @@
extends Node2D
-# member variables here, example:
-# var a=2
-# var b="textvar"
-
+# member variables
var thread = Thread.new()
-#this function runs in a thread!
-#threads always take one userdata argument
+
+# this function runs in a thread!
+# threads always take one userdata argument
func _bg_load(path):
print("THREAD FUNC!")
- #load the resource
+ # load the resource
var tex = ResourceLoader.load(path)
- #call _bg_load_done on main thread
+ # call _bg_load_done on main thread
call_deferred("_bg_load_done")
- return tex #return it
+ return tex # return it
+
func _bg_load_done():
- #wait for the thread to complete, get the returned value
+ # wait for the thread to complete, get the returned value
var tex = thread.wait_to_finish()
- #set to the sprite
+ # set to the sprite
get_node("sprite").set_texture(tex)
+
func _on_load_pressed():
if (thread.is_active()):
- #already working
+ # already working
return
print("START THREAD!")
- thread.start(self,"_bg_load","res://mona.png")
+ thread.start(self, "_bg_load", "res://mona.png")
diff --git a/demos/misc/threads/thread.scn b/demos/misc/threads/thread.scn
index 349127529..eea93615c 100644
--- a/demos/misc/threads/thread.scn
+++ b/demos/misc/threads/thread.scn
Binary files differ