diff options
| author | Rémi Verschelde | 2015-12-09 08:38:23 +0100 |
|---|---|---|
| committer | Rémi Verschelde | 2015-12-09 08:38:23 +0100 |
| commit | 8639cecf4cedd56452b47503be19c44b304cd02f (patch) | |
| tree | e2a795da15e40c7d9d5b82e33378f8dbf0eaf67a /demos/misc/threads | |
| parent | efbb834936fdc9da9789ad37c9cc61e0b90cda95 (diff) | |
| download | godot-8639cecf4cedd56452b47503be19c44b304cd02f.tar.gz godot-8639cecf4cedd56452b47503be19c44b304cd02f.tar.zst godot-8639cecf4cedd56452b47503be19c44b304cd02f.zip | |
Diffstat (limited to 'demos/misc/threads')
| -rw-r--r-- | demos/misc/threads/thread.gd | 26 | ||||
| -rw-r--r-- | demos/misc/threads/thread.scn | bin | 1638 -> 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 Binary files differindex 349127529..eea93615c 100644 --- a/demos/misc/threads/thread.scn +++ b/demos/misc/threads/thread.scn |
