From 8639cecf4cedd56452b47503be19c44b304cd02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 9 Dec 2015 08:38:23 +0100 Subject: Improve code formatting and update to 2.0 The scripts were streamlined using more or less the following conventions: - space after a comma in lists of arguments - space around weak operators (+, -), no space around strong operators (*, /) - space after a comment start (#) - removed trailing spaces or tabs, apart from those that delimit the function indentation level (those could be removed too but since they are added automatically by the editor when typing code, keeping them for now) - function blocks separate by two newlines The scene files were resaved with the (current) 2.0 format, and some scenes that were in XML format were converted to SCN, to be consistent across all demos. --- demos/misc/threads/thread.gd | 26 +++++++++++++------------- demos/misc/threads/thread.scn | Bin 1638 -> 1586 bytes 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'demos/misc/threads') diff --git a/demos/misc/threads/thread.gd b/demos/misc/threads/thread.gd index 7d8aabd1b7..fbfd68af2b 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 349127529a..eea93615c7 100644 Binary files a/demos/misc/threads/thread.scn and b/demos/misc/threads/thread.scn differ -- cgit v1.2.3