summaryrefslogtreecommitdiff
path: root/demos/misc
diff options
context:
space:
mode:
Diffstat (limited to 'demos/misc')
-rw-r--r--demos/misc/autoload/global.gd41
-rw-r--r--demos/misc/autoload/scene_a.gd12
-rw-r--r--demos/misc/autoload/scene_a.scnbin1459 -> 1660 bytes
-rw-r--r--demos/misc/autoload/scene_b.gd12
-rw-r--r--demos/misc/autoload/scene_b.scnbin1448 -> 1639 bytes
-rw-r--r--demos/misc/instancing/ball.scnbin1563 -> 1885 bytes
-rw-r--r--demos/misc/instancing/container.scnbin2312 -> 3137 bytes
-rw-r--r--demos/misc/joysticks/diagram.pngbin0 -> 171519 bytes
-rw-r--r--demos/misc/joysticks/engine.cfg2
-rw-r--r--demos/misc/joysticks/indicators.pngbin0 -> 1069 bytes
-rw-r--r--demos/misc/joysticks/joysticks.gd49
-rw-r--r--demos/misc/joysticks/joysticks.scnbin3809 -> 4356 bytes
-rw-r--r--demos/misc/joysticks/jsdiagram.xscn115
-rw-r--r--demos/misc/pause/spinpause.gd2
-rw-r--r--demos/misc/pause/spinpause.scnbin3331 -> 5399 bytes
-rw-r--r--demos/misc/regex/regex.gd6
-rw-r--r--demos/misc/regex/regex.scnbin1793 -> 1775 bytes
-rw-r--r--demos/misc/scene_changer/scene_a.gd7
-rw-r--r--demos/misc/scene_changer/scene_a.scnbin1459 -> 1660 bytes
-rw-r--r--demos/misc/scene_changer/scene_b.gd7
-rw-r--r--demos/misc/scene_changer/scene_b.scnbin1448 -> 1639 bytes
-rw-r--r--demos/misc/threads/thread.gd26
-rw-r--r--demos/misc/threads/thread.scnbin1638 -> 1586 bytes
-rw-r--r--demos/misc/tween/engine.cfg2
-rw-r--r--demos/misc/tween/main.gd53
-rw-r--r--demos/misc/tween/main.scnbin0 -> 5216 bytes
-rw-r--r--demos/misc/tween/main.xml367
-rw-r--r--demos/misc/udp_chat/chat.gd46
-rw-r--r--demos/misc/udp_chat/chat.scnbin3198 -> 3359 bytes
-rw-r--r--demos/misc/window_management/control.gd85
-rw-r--r--demos/misc/window_management/observer/observer.gd31
-rw-r--r--demos/misc/window_management/observer/observer.scnbin1786 -> 3824 bytes
-rw-r--r--demos/misc/window_management/window_management.scnbin5132 -> 4384 bytes
33 files changed, 294 insertions, 569 deletions
diff --git a/demos/misc/autoload/global.gd b/demos/misc/autoload/global.gd
index d1bd45461f..735995e806 100644
--- a/demos/misc/autoload/global.gd
+++ b/demos/misc/autoload/global.gd
@@ -1,43 +1,36 @@
extends Node
-var current_scene = null
+# Changing scenes is most easily done using the functions `change_scene`
+# and `change_scene_to` of the SceneTree. This script demonstrates how to
+# change scenes without those helpers.
func goto_scene(path):
-
# This function will usually be called from a signal callback,
# or some other function from the running scene.
# Deleting the current scene at this point might be
# a bad idea, because it may be inside of a callback or function of it.
# The worst case will be a crash or unexpected behavior.
-
+
# The way around this is deferring the load to a later time, when
# it is ensured that no code from the current scene is running:
-
+
call_deferred("_deferred_goto_scene",path)
func _deferred_goto_scene(path):
-
- # Immediately free the current scene,
- # there is no risk here.
- current_scene.free()
-
+ # Immediately free the current scene, there is no risk here.
+ get_tree().get_current_scene().free()
+
# Load new scene
- var s = ResourceLoader.load(path)
-
+ var packed_scene = ResourceLoader.load(path)
+
# Instance the new scene
- current_scene = s.instance()
-
- # Add it to the active scene, as child of root
- get_tree().get_root().add_child(current_scene)
-
-
-func _ready():
- # Get the current scene, the first time.
- # it is always the last child of root,
- # after the autoloaded nodes.
-
- var root = get_tree().get_root()
- current_scene = root.get_child( root.get_child_count() -1 )
+ var instanced_scene = packed_scene.instance()
+
+ # Add it to the scene tree, as direct child of root
+ get_tree().get_root().add_child(instanced_scene)
+
+ # Set it as the current scene, only after it has been added to the tree
+ get_tree().set_current_scene(instanced_scene)
diff --git a/demos/misc/autoload/scene_a.gd b/demos/misc/autoload/scene_a.gd
index 21a6a84eb9..03da86d9a0 100644
--- a/demos/misc/autoload/scene_a.gd
+++ b/demos/misc/autoload/scene_a.gd
@@ -1,17 +1,5 @@
-
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
index 61727a57ba..eff314e29d 100644
--- a/demos/misc/autoload/scene_a.scn
+++ 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
index 4a88fddda9..dea8c4623f 100644
--- a/demos/misc/autoload/scene_b.gd
+++ b/demos/misc/autoload/scene_b.gd
@@ -1,17 +1,5 @@
-
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
index ae09eeff88..4cdb03e90e 100644
--- a/demos/misc/autoload/scene_b.scn
+++ b/demos/misc/autoload/scene_b.scn
Binary files differ
diff --git a/demos/misc/instancing/ball.scn b/demos/misc/instancing/ball.scn
index 81c222a306..4d6367885e 100644
--- a/demos/misc/instancing/ball.scn
+++ b/demos/misc/instancing/ball.scn
Binary files differ
diff --git a/demos/misc/instancing/container.scn b/demos/misc/instancing/container.scn
index 9a365ac494..0f65daa2ca 100644
--- a/demos/misc/instancing/container.scn
+++ b/demos/misc/instancing/container.scn
Binary files differ
diff --git a/demos/misc/joysticks/diagram.png b/demos/misc/joysticks/diagram.png
new file mode 100644
index 0000000000..3f8ba1f973
--- /dev/null
+++ b/demos/misc/joysticks/diagram.png
Binary files differ
diff --git a/demos/misc/joysticks/engine.cfg b/demos/misc/joysticks/engine.cfg
index 71ac91000e..79cda1eeb4 100644
--- a/demos/misc/joysticks/engine.cfg
+++ b/demos/misc/joysticks/engine.cfg
@@ -6,5 +6,5 @@ icon="res://icon.png"
[display]
-width=260
+width=550
height=300
diff --git a/demos/misc/joysticks/indicators.png b/demos/misc/joysticks/indicators.png
new file mode 100644
index 0000000000..90fee48498
--- /dev/null
+++ b/demos/misc/joysticks/indicators.png
Binary files differ
diff --git a/demos/misc/joysticks/joysticks.gd b/demos/misc/joysticks/joysticks.gd
index d359e993e6..f5bc1bddad 100644
--- a/demos/misc/joysticks/joysticks.gd
+++ b/demos/misc/joysticks/joysticks.gd
@@ -8,33 +8,46 @@ extends Node2D
#
# Licensed under the MIT license
+# Member variables
var joy_num
var cur_joy
var axis_value
var btn_state
-func _ready():
- set_process_input(true)
+const DEADZONE = 0.2
-func _input(ev):
- # get the joystick device number from the spinbox
+func _fixed_process(delta):
+ # Get the joystick device number from the spinbox
joy_num = get_node("joy_num").get_value()
-
- # display the name of the joystick if we haven't already
+
+ # Display the name of the joystick if we haven't already
if joy_num != cur_joy:
cur_joy = joy_num
- get_node("joy_name").set_text( Input.get_joy_name(joy_num) )
-
- # loop through the axes and show their current values
- for axis in range(0,8):
- axis_value = Input.get_joy_axis(joy_num,axis)
- get_node("axis_prog"+str(axis)).set_value(100*axis_value)
- get_node("axis_val"+str(axis)).set_text(str(axis_value))
-
- # loop through the buttons and highlight the ones that are pressed
- for btn in range(0,17):
+ get_node("joy_name").set_text(Input.get_joy_name(joy_num))
+
+ # Loop through the axes and show their current values
+ for axis in range(0, 8):
+ axis_value = Input.get_joy_axis(joy_num, axis)
+ get_node("axis_prog" + str(axis)).set_value(100*axis_value)
+ get_node("axis_val" + str(axis)).set_text(str(axis_value))
+ if (axis < 4):
+ if (abs(axis_value) < DEADZONE):
+ get_node("diagram/axes/" + str(axis) + "+").hide()
+ get_node("diagram/axes/" + str(axis) + "-").hide()
+ elif (axis_value > 0):
+ get_node("diagram/axes/" + str(axis) + "+").show()
+ else:
+ get_node("diagram/axes/" + str(axis) + "-").show()
+
+ # Loop through the buttons and highlight the ones that are pressed
+ for btn in range(0, 16):
btn_state = 1
if (Input.is_joy_button_pressed(joy_num, btn)):
- get_node("btn"+str(btn)).add_color_override("font_color",Color(1,1,1,1))
+ get_node("btn" + str(btn)).add_color_override("font_color", Color(1, 1, 1, 1))
+ get_node("diagram/buttons/" + str(btn)).show()
else:
- get_node("btn"+str(btn)).add_color_override("font_color",Color(0.2,0.1,0.3,1))
+ get_node("btn" + str(btn)).add_color_override("font_color", Color(0.2, 0.1, 0.3, 1))
+ get_node("diagram/buttons/" + str(btn)).hide()
+
+func _ready():
+ set_fixed_process(true)
diff --git a/demos/misc/joysticks/joysticks.scn b/demos/misc/joysticks/joysticks.scn
index 5dbd7f49bf..3e0f326a0d 100644
--- a/demos/misc/joysticks/joysticks.scn
+++ b/demos/misc/joysticks/joysticks.scn
Binary files differ
diff --git a/demos/misc/joysticks/jsdiagram.xscn b/demos/misc/joysticks/jsdiagram.xscn
new file mode 100644
index 0000000000..537ad30278
--- /dev/null
+++ b/demos/misc/joysticks/jsdiagram.xscn
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<resource_file type="PackedScene" subresource_count="3" version="2.0" version_name="Godot Engine v2.0.alpha.custom_build">
+ <ext_resource path="res://indicators.png" type="Texture" index="1"></ext_resource>
+ <ext_resource path="res://diagram.png" type="Texture" index="0"></ext_resource>
+ <main_resource>
+ <dictionary name="_bundled" shared="false">
+ <string> "conn_count" </string>
+ <int> 0 </int>
+ <string> "conns" </string>
+ <int_array len="0"> </int_array>
+ <string> "editable_instances" </string>
+ <array len="0" shared="false">
+ </array>
+ <string> "names" </string>
+ <string_array len="37">
+ <string> "diagram" </string>
+ <string> "transform/pos" </string>
+ <string> "transform/scale" </string>
+ <string> "texture" </string>
+ <string> "__meta__" </string>
+ <string> "Sprite" </string>
+ <string> "buttons" </string>
+ <string> "Node2D" </string>
+ <string> "0" </string>
+ <string> "region" </string>
+ <string> "region_rect" </string>
+ <string> "1" </string>
+ <string> "2" </string>
+ <string> "3" </string>
+ <string> "4" </string>
+ <string> "5" </string>
+ <string> "6" </string>
+ <string> "flip_h" </string>
+ <string> "7" </string>
+ <string> "8" </string>
+ <string> "9" </string>
+ <string> "10" </string>
+ <string> "11" </string>
+ <string> "12" </string>
+ <string> "13" </string>
+ <string> "flip_v" </string>
+ <string> "14" </string>
+ <string> "15" </string>
+ <string> "axes" </string>
+ <string> "0-" </string>
+ <string> "0+" </string>
+ <string> "1-" </string>
+ <string> "1+" </string>
+ <string> "3-" </string>
+ <string> "3+" </string>
+ <string> "2-" </string>
+ <string> "2+" </string>
+ </string_array>
+ <string> "node_count" </string>
+ <int> 27 </int>
+ <string> "node_paths" </string>
+ <array len="0" shared="false">
+ </array>
+ <string> "nodes" </string>
+ <int_array len="453"> -1, -1, 5, 0, -1, 4, 1, 0, 2, 1, 3, 2, 4, 3, 0, 0, 0, 7, 6, -1, 1, 4, 4, 0, 1, 0, 5, 8, -1, 5, 1, 5, 2, 6, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 11, -1, 5, 1, 10, 2, 6, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 12, -1, 5, 1, 11, 2, 6, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 13, -1, 5, 1, 12, 2, 6, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 14, -1, 5, 1, 13, 2, 14, 3, 7, 9, 8, 10, 15, 0, 1, 0, 5, 15, -1, 5, 1, 16, 2, 14, 3, 7, 9, 8, 10, 15, 0, 1, 0, 5, 16, -1, 6, 1, 17, 2, 18, 3, 7, 17, 8, 9, 8, 10, 19, 0, 1, 0, 5, 18, -1, 5, 1, 20, 2, 18, 3, 7, 9, 8, 10, 19, 0, 1, 0, 5, 19, -1, 5, 1, 21, 2, 6, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 20, -1, 5, 1, 22, 2, 6, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 21, -1, 5, 1, 23, 2, 24, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 22, -1, 5, 1, 25, 2, 24, 3, 7, 9, 8, 10, 9, 0, 1, 0, 5, 23, -1, 5, 1, 26, 2, 6, 3, 7, 9, 8, 10, 27, 0, 1, 0, 5, 24, -1, 6, 1, 28, 2, 6, 3, 7, 25, 8, 9, 8, 10, 27, 0, 1, 0, 5, 26, -1, 5, 1, 29, 2, 6, 3, 7, 9, 8, 10, 30, 0, 1, 0, 5, 27, -1, 6, 1, 31, 2, 6, 3, 7, 17, 8, 9, 8, 10, 30, 0, 0, 0, 7, 28, -1, 0, 0, 18, 0, 5, 29, -1, 5, 1, 32, 2, 6, 3, 7, 9, 8, 10, 30, 0, 18, 0, 5, 30, -1, 6, 1, 33, 2, 6, 3, 7, 17, 8, 9, 8, 10, 30, 0, 18, 0, 5, 31, -1, 5, 1, 34, 2, 6, 3, 7, 9, 8, 10, 27, 0, 18, 0, 5, 32, -1, 6, 1, 35, 2, 6, 3, 7, 25, 8, 9, 8, 10, 27, 0, 18, 0, 5, 33, -1, 5, 1, 36, 2, 6, 3, 7, 9, 8, 10, 27, 0, 18, 0, 5, 34, -1, 6, 1, 37, 2, 6, 3, 7, 25, 8, 9, 8, 10, 27, 0, 18, 0, 5, 35, -1, 5, 1, 38, 2, 6, 3, 7, 9, 8, 10, 30, 0, 18, 0, 5, 36, -1, 6, 1, 39, 2, 6, 3, 7, 17, 8, 9, 8, 10, 30, 0 </int_array>
+ <string> "variants" </string>
+ <array len="40" shared="false">
+ <vector2> 368.635, 155.289 </vector2>
+ <vector2> 0.432859, 0.446287 </vector2>
+ <resource external="0"> </resource>
+ <dictionary shared="false">
+ <string> "__editor_plugin_screen__" </string>
+ <string> "2D" </string>
+ </dictionary>
+ <dictionary shared="false">
+ <string> "_editor_collapsed" </string>
+ <bool> True </bool>
+ </dictionary>
+ <vector2> 147.73, 120.925 </vector2>
+ <vector2> 0.9, 0.9 </vector2>
+ <resource external="1"> </resource>
+ <bool> True </bool>
+ <rect2> 0, 0, 45, 45 </rect2>
+ <vector2> 185.769, 82.4874 </vector2>
+ <vector2> 112.377, 82.4874 </vector2>
+ <vector2> 149.073, 47.3293 </vector2>
+ <vector2> -161.038, -158.037 </vector2>
+ <vector2> 5.3348, 3.35512 </vector2>
+ <rect2> 10, 10, 10, 10 </rect2>
+ <vector2> 159.362, -156.977 </vector2>
+ <vector2> -159.349, -221.878 </vector2>
+ <vector2> 1.0458, 2.16952 </vector2>
+ <rect2> 0, 0, 45, 22 </rect2>
+ <vector2> 156.677, -220.11 </vector2>
+ <vector2> -67.5308, 164.422 </vector2>
+ <vector2> 75.8825, 167.363 </vector2>
+ <vector2> -46.6707, 52.702 </vector2>
+ <vector2> 0.810497, 0.57205 </vector2>
+ <vector2> 56.2581, 54.4382 </vector2>
+ <vector2> -139.402, 46.8295 </vector2>
+ <rect2> 50, 0, 54, 14 </rect2>
+ <vector2> -139.838, 115.789 </vector2>
+ <vector2> -172.262, 81.8793 </vector2>
+ <rect2> 50, 0, 14, 54 </rect2>
+ <vector2> -105.085, 81.0326 </vector2>
+ <vector2> -94.4295, 164.932 </vector2>
+ <vector2> -40.3475, 164.509 </vector2>
+ <vector2> -67.6802, 137.926 </vector2>
+ <vector2> -67.4618, 192.915 </vector2>
+ <vector2> 76.6557, 140.986 </vector2>
+ <vector2> 76.0009, 195.339 </vector2>
+ <vector2> 48.8152, 167.145 </vector2>
+ <vector2> 102.899, 167.857 </vector2>
+ </array>
+ <string> "version" </string>
+ <int> 2 </int>
+ </dictionary>
+
+ </main_resource>
+</resource_file> \ No newline at end of file
diff --git a/demos/misc/pause/spinpause.gd b/demos/misc/pause/spinpause.gd
index 1b8f8388f0..ea5617c06f 100644
--- a/demos/misc/pause/spinpause.gd
+++ b/demos/misc/pause/spinpause.gd
@@ -11,5 +11,3 @@ func _on_pause_pressed():
func _on_unpause_pressed():
get_node("pause_popup").hide()
get_tree().set_pause(false)
-
-
diff --git a/demos/misc/pause/spinpause.scn b/demos/misc/pause/spinpause.scn
index a3835c4374..2cbe85ec9a 100644
--- a/demos/misc/pause/spinpause.scn
+++ b/demos/misc/pause/spinpause.scn
Binary files differ
diff --git a/demos/misc/regex/regex.gd b/demos/misc/regex/regex.gd
index 409b4cab05..98e5ca8828 100644
--- a/demos/misc/regex/regex.gd
+++ b/demos/misc/regex/regex.gd
@@ -1,11 +1,15 @@
+
extends VBoxContainer
+# Member variables
var regex = RegEx.new()
+
func update_expression(text):
regex.compile(text)
update_text()
+
func update_text():
var text = get_node("Text").get_text()
var list = get_node("List")
@@ -18,7 +22,7 @@ func update_text():
label.set_text(res)
list.add_child(label)
+
func _ready():
get_node("Text").set_text("They asked me \"What's going on \\\"in the manor\\\"?\"")
update_expression(get_node("Expression").get_text())
-
diff --git a/demos/misc/regex/regex.scn b/demos/misc/regex/regex.scn
index 1f46521d0d..debd55504f 100644
--- a/demos/misc/regex/regex.scn
+++ b/demos/misc/regex/regex.scn
Binary files differ
diff --git a/demos/misc/scene_changer/scene_a.gd b/demos/misc/scene_changer/scene_a.gd
index 956878b0f7..0e80395e84 100644
--- a/demos/misc/scene_changer/scene_a.gd
+++ b/demos/misc/scene_changer/scene_a.gd
@@ -1,17 +1,16 @@
extends Panel
-# member variables here, example:
+# Member variables here, example:
# var a=2
# var b="textvar"
+
func _ready():
# Initalization here
pass
-
-
func _on_goto_scene_pressed():
get_tree().change_scene("res://scene_b.scn")
- pass # replace with function body
+ pass # Replace with function body
diff --git a/demos/misc/scene_changer/scene_a.scn b/demos/misc/scene_changer/scene_a.scn
index 61727a57ba..9a4b6434be 100644
--- a/demos/misc/scene_changer/scene_a.scn
+++ b/demos/misc/scene_changer/scene_a.scn
Binary files differ
diff --git a/demos/misc/scene_changer/scene_b.gd b/demos/misc/scene_changer/scene_b.gd
index 4f94d6bb8f..9ed13cf26b 100644
--- a/demos/misc/scene_changer/scene_b.gd
+++ b/demos/misc/scene_changer/scene_b.gd
@@ -1,17 +1,16 @@
extends Panel
-# member variables here, example:
+# Member variables here, example:
# var a=2
# var b="textvar"
+
func _ready():
# Initalization here
pass
-
-
func _on_goto_scene_pressed():
get_tree().change_scene("res://scene_a.scn")
- pass # replace with function body
+ pass # Replace with function body
diff --git a/demos/misc/scene_changer/scene_b.scn b/demos/misc/scene_changer/scene_b.scn
index ae09eeff88..4cdb03e90e 100644
--- a/demos/misc/scene_changer/scene_b.scn
+++ b/demos/misc/scene_changer/scene_b.scn
Binary files differ
diff --git a/demos/misc/threads/thread.gd b/demos/misc/threads/thread.gd
index 7d8aabd1b7..1ef67e403c 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
--- a/demos/misc/threads/thread.scn
+++ b/demos/misc/threads/thread.scn
Binary files differ
diff --git a/demos/misc/tween/engine.cfg b/demos/misc/tween/engine.cfg
index 3d3d639964..1d87303015 100644
--- a/demos/misc/tween/engine.cfg
+++ b/demos/misc/tween/engine.cfg
@@ -1,7 +1,7 @@
[application]
name="Tween Demo"
-main_scene="res://main.xml"
+main_scene="res://main.scn"
icon="res://icon.png"
target_fps=60
diff --git a/demos/misc/tween/main.gd b/demos/misc/tween/main.gd
index a0106a7682..512271311e 100644
--- a/demos/misc/tween/main.gd
+++ b/demos/misc/tween/main.gd
@@ -1,10 +1,7 @@
extends Control
-# member variables here, example:
-# var a=2
-# var b="textvar"
-
+# Member variables
var trans = ["linear", "sine", "quint", "quart", "quad", "expo", "elastic", "cubic", "circ", "bounce", "back"]
var eases = ["in", "out", "in_out", "out_in"]
var modes = ["move", "color", "scale", "rotate", "callback", "follow", "repeat", "pause"]
@@ -14,6 +11,7 @@ var state = {
eases = Tween.EASE_IN,
}
+
func _ready():
for index in range(trans.size()):
var name = trans[index]
@@ -39,9 +37,7 @@ func _ready():
get_node("modes/repeat").set_pressed(true)
reset_tween()
-
- # Initalization here
- pass
+
func on_trans_changed(name, index):
for index in range(trans.size()):
@@ -53,7 +49,8 @@ func on_trans_changed(name, index):
state.trans = index
reset_tween()
-
+
+
func on_eases_changed(name, index):
for index in range(eases.size()):
var pressed = eases[index] == name
@@ -64,7 +61,8 @@ func on_eases_changed(name, index):
state.eases = index
reset_tween()
-
+
+
func on_modes_changed(name):
var tween = get_node("tween")
if name == "pause":
@@ -76,10 +74,12 @@ func on_modes_changed(name):
get_node("timeline").set_ignore_mouse(true)
else:
reset_tween()
-
+
+
func on_color_changed(color):
reset_tween()
-
+
+
func reset_tween():
var tween = get_node("tween")
var pos = tween.tell()
@@ -92,20 +92,20 @@ func reset_tween():
var size = get_node("tween/area").get_size()
if get_node("modes/move").is_pressed():
- tween.interpolate_method(sprite, "set_pos", Vector2(0,0), Vector2(size.width, size.height), 2, state.trans, state.eases)
- tween.interpolate_property(sprite, "transform/pos", Vector2(size.width,size.height), Vector2(0, 0), 2, state.trans, state.eases, 2)
+ tween.interpolate_method(sprite, "set_pos", Vector2(0, 0), Vector2(size.width, size.height), 2, state.trans, state.eases)
+ tween.interpolate_property(sprite, "transform/pos", Vector2(size.width, size.height), Vector2(0, 0), 2, state.trans, state.eases, 2)
if get_node("modes/color").is_pressed():
tween.interpolate_method(sprite, "set_modulate", get_node("color/color_from").get_color(), get_node("color/color_to").get_color(), 2, state.trans, state.eases)
tween.interpolate_property(sprite, "modulate", get_node("color/color_to").get_color(), get_node("color/color_from").get_color(), 2, state.trans, state.eases, 2)
else:
- sprite.set_modulate(Color(1, 1, 1, 1))
+ sprite.set_modulate(Color(1,1,1,1))
if get_node("modes/scale").is_pressed():
- tween.interpolate_method(sprite, "set_scale", Vector2(0.5,0.5), Vector2(1.5, 1.5), 2, state.trans, state.eases)
- tween.interpolate_property(sprite, "transform/scale", Vector2(1.5,1.5), Vector2(0.5, 0.5), 2, state.trans, state.eases, 2)
+ tween.interpolate_method(sprite, "set_scale", Vector2(0.5, 0.5), Vector2(1.5, 1.5), 2, state.trans, state.eases)
+ tween.interpolate_property(sprite, "transform/scale", Vector2(1.5, 1.5), Vector2(0.5, 0.5), 2, state.trans, state.eases, 2)
else:
- sprite.set_scale(Vector2(1, 1))
+ sprite.set_scale(Vector2(1,1))
if get_node("modes/rotate").is_pressed():
tween.interpolate_method(sprite, "_set_rotd", 0, 360, 2, state.trans, state.eases)
@@ -139,26 +139,27 @@ func reset_tween():
else:
tween.resume_all()
get_node("timeline").set_ignore_mouse(true)
-
-func _on_tween_step( object, key, elapsed, value ):
- var timeline = get_node("timeline")
+func _on_tween_step(object, key, elapsed, value):
+ var timeline = get_node("timeline")
+
var tween = get_node("tween")
var runtime = tween.get_runtime()
-
- var ratio = 100 * (elapsed / runtime)
- timeline.set_value(ratio)
+ var ratio = 100*(elapsed/runtime)
+ timeline.set_value(ratio)
+
-func _on_timeline_value_changed( value ):
+func _on_timeline_value_changed(value):
if !get_node("modes/pause").is_pressed():
return
var tween = get_node("tween")
var runtime = tween.get_runtime()
- tween.seek(runtime * value / 100)
-
+ tween.seek(runtime*value/100)
+
+
func on_callback(arg):
var label = get_node("tween/area/label")
label.add_text("on_callback -> " + arg + "\n")
diff --git a/demos/misc/tween/main.scn b/demos/misc/tween/main.scn
new file mode 100644
index 0000000000..3f25bfd75c
--- /dev/null
+++ b/demos/misc/tween/main.scn
Binary files differ
diff --git a/demos/misc/tween/main.xml b/demos/misc/tween/main.xml
deleted file mode 100644
index 6580ba04da..0000000000
--- a/demos/misc/tween/main.xml
+++ /dev/null
@@ -1,367 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<resource_file type="PackedScene" subresource_count="3" version="1.0" version_name="Godot Engine v1.0.3917-beta1">
- <ext_resource path="res://icon.png" type="Texture"></ext_resource>
- <ext_resource path="res://main.gd" type="Script"></ext_resource>
- <main_resource>
- <dictionary name="_bundled" shared="false">
- <string> "names" </string>
- <string_array len="115">
- <string> "main" </string>
- <string> "Control" </string>
- <string> "_import_path" </string>
- <string> "visibility/visible" </string>
- <string> "visibility/opacity" </string>
- <string> "visibility/self_opacity" </string>
- <string> "visibility/behind_parent" </string>
- <string> "margin/right" </string>
- <string> "margin/bottom" </string>
- <string> "transform/rot" </string>
- <string> "transform/scale" </string>
- <string> "focus_neighbour/left" </string>
- <string> "focus_neighbour/top" </string>
- <string> "focus_neighbour/right" </string>
- <string> "focus_neighbour/bottom" </string>
- <string> "focus/ignore_mouse" </string>
- <string> "focus/stop_mouse" </string>
- <string> "size_flags/horizontal" </string>
- <string> "size_flags/vertical" </string>
- <string> "size_flags/stretch_ratio" </string>
- <string> "script/script" </string>
- <string> "__meta__" </string>
- <string> "trans" </string>
- <string> "VBoxContainer" </string>
- <string> "margin/left" </string>
- <string> "margin/top" </string>
- <string> "linear" </string>
- <string> "Button" </string>
- <string> "disabled" </string>
- <string> "pressed" </string>
- <string> "toggle_mode" </string>
- <string> "click_on_press" </string>
- <string> "text" </string>
- <string> "icon" </string>
- <string> "flat" </string>
- <string> "clip_text" </string>
- <string> "align" </string>
- <string> "sine" </string>
- <string> "quint" </string>
- <string> "quart" </string>
- <string> "quad" </string>
- <string> "expo" </string>
- <string> "elastic" </string>
- <string> "cubic" </string>
- <string> "circ" </string>
- <string> "bounce" </string>
- <string> "back" </string>
- <string> "eases" </string>
- <string> "in" </string>
- <string> "out" </string>
- <string> "in_out" </string>
- <string> "out_in" </string>
- <string> "modes" </string>
- <string> "move" </string>
- <string> "color" </string>
- <string> "scale" </string>
- <string> "rotate" </string>
- <string> "callback" </string>
- <string> "follow" </string>
- <string> "repeat" </string>
- <string> "pause" </string>
- <string> "label_1" </string>
- <string> "Label" </string>
- <string> "range/min" </string>
- <string> "range/max" </string>
- <string> "range/step" </string>
- <string> "range/page" </string>
- <string> "range/value" </string>
- <string> "range/exp_edit" </string>
- <string> "rounded_values" </string>
- <string> "valign" </string>
- <string> "autowrap" </string>
- <string> "uppercase" </string>
- <string> "percent_visible" </string>
- <string> "color_from" </string>
- <string> "ColorPicker" </string>
- <string> "label_2" </string>
- <string> "color_to" </string>
- <string> "tween" </string>
- <string> "Tween" </string>
- <string> "playback/process_mode" </string>
- <string> "playback/active" </string>
- <string> "playback/repeat" </string>
- <string> "playback/speed" </string>
- <string> "area" </string>
- <string> "Panel" </string>
- <string> "label" </string>
- <string> "RichTextLabel" </string>
- <string> "scroll_active" </string>
- <string> "scroll_follow" </string>
- <string> "tab_size" </string>
- <string> "selection_enabled" </string>
- <string> "sprite" </string>
- <string> "Sprite" </string>
- <string> "transform/pos" </string>
- <string> "texture" </string>
- <string> "centered" </string>
- <string> "offset" </string>
- <string> "flip_h" </string>
- <string> "flip_v" </string>
- <string> "vframes" </string>
- <string> "hframes" </string>
- <string> "frame" </string>
- <string> "modulate" </string>
- <string> "region" </string>
- <string> "region_rect" </string>
- <string> "follow_2" </string>
- <string> "timeline" </string>
- <string> "HSlider" </string>
- <string> "tick_count" </string>
- <string> "ticks_on_borders" </string>
- <string> "_on_tween_step" </string>
- <string> "tween_step" </string>
- <string> "_on_timeline_value_changed" </string>
- <string> "value_changed" </string>
- </string_array>
- <string> "version" </string>
- <int> 1 </int>
- <string> "conn_count" </string>
- <int> 2 </int>
- <string> "node_count" </string>
- <int> 39 </int>
- <string> "variants" </string>
- <array len="104" shared="false">
- <node_path> "" </node_path>
- <bool> True </bool>
- <real> 1 </real>
- <bool> False </bool>
- <real> 800 </real>
- <real> 600 </real>
- <real> 0 </real>
- <vector2> 1, 1 </vector2>
- <int> 2 </int>
- <resource resource_type="Script" path="res://main.gd"> </resource>
- <dictionary shared="false">
- <string> "__editor_plugin_states__" </string>
- <dictionary shared="false">
- <string> "Script" </string>
- <dictionary shared="false">
- <string> "current" </string>
- <int> 0 </int>
- <string> "sources" </string>
- <array len="1" shared="false">
- <string> "res://main.gd" </string>
- </array>
- </dictionary>
- <string> "2D" </string>
- <dictionary shared="false">
- <string> "pixel_snap" </string>
- <bool> False </bool>
- <string> "zoom" </string>
- <real> 1.360374 </real>
- <string> "use_snap" </string>
- <bool> True </bool>
- <string> "ofs" </string>
- <vector2> -215.073, -20.8125 </vector2>
- <string> "snap" </string>
- <int> 8 </int>
- </dictionary>
- <string> "3D" </string>
- <dictionary shared="false">
- <string> "zfar" </string>
- <real> 500 </real>
- <string> "fov" </string>
- <real> 45 </real>
- <string> "viewports" </string>
- <array len="4" shared="false">
- <dictionary shared="false">
- <string> "distance" </string>
- <real> 4 </real>
- <string> "x_rot" </string>
- <real> 0 </real>
- <string> "y_rot" </string>
- <real> 0 </real>
- <string> "use_orthogonal" </string>
- <bool> False </bool>
- <string> "use_environment" </string>
- <bool> False </bool>
- <string> "pos" </string>
- <vector3> 0, 0, 0 </vector3>
- </dictionary>
- <dictionary shared="false">
- <string> "distance" </string>
- <real> 4 </real>
- <string> "x_rot" </string>
- <real> 0 </real>
- <string> "y_rot" </string>
- <real> 0 </real>
- <string> "use_orthogonal" </string>
- <bool> False </bool>
- <string> "use_environment" </string>
- <bool> False </bool>
- <string> "pos" </string>
- <vector3> 0, 0, 0 </vector3>
- </dictionary>
- <dictionary shared="false">
- <string> "distance" </string>
- <real> 4 </real>
- <string> "x_rot" </string>
- <real> 0 </real>
- <string> "y_rot" </string>
- <real> 0 </real>
- <string> "use_orthogonal" </string>
- <bool> False </bool>
- <string> "use_environment" </string>
- <bool> False </bool>
- <string> "pos" </string>
- <vector3> 0, 0, 0 </vector3>
- </dictionary>
- <dictionary shared="false">
- <string> "distance" </string>
- <real> 4 </real>
- <string> "x_rot" </string>
- <real> 0 </real>
- <string> "y_rot" </string>
- <real> 0 </real>
- <string> "use_orthogonal" </string>
- <bool> False </bool>
- <string> "use_environment" </string>
- <bool> False </bool>
- <string> "pos" </string>
- <vector3> 0, 0, 0 </vector3>
- </dictionary>
- </array>
- <string> "viewport_mode" </string>
- <int> 1 </int>
- <string> "default_light" </string>
- <bool> True </bool>
- <string> "show_grid" </string>
- <bool> True </bool>
- <string> "show_origin" </string>
- <bool> True </bool>
- <string> "znear" </string>
- <real> 0.1 </real>
- </dictionary>
- </dictionary>
- <string> "__editor_run_settings__" </string>
- <dictionary shared="false">
- <string> "custom_args" </string>
- <string> "-l $scene" </string>
- <string> "run_mode" </string>
- <int> 0 </int>
- </dictionary>
- <string> "__editor_plugin_screen__" </string>
- <string> "Script" </string>
- </dictionary>
- <real> 56 </real>
- <real> 256 </real>
- <real> 129 </real>
- <real> 582 </real>
- <dictionary shared="false">
- <string> "_editor_collapsed" </string>
- <bool> True </bool>
- </dictionary>
- <real> 73 </real>
- <real> 26 </real>
- <string> "linear" </string>
- <resource name=""></resource> <int> 1 </int>
- <real> 30 </real>
- <string> "sine" </string>
- <real> 60 </real>
- <real> 86 </real>
- <string> "quint" </string>
- <real> 90 </real>
- <real> 116 </real>
- <string> "quart" </string>
- <real> 120 </real>
- <real> 146 </real>
- <string> "quad" </string>
- <real> 150 </real>
- <real> 176 </real>
- <string> "expo" </string>
- <real> 180 </real>
- <real> 206 </real>
- <string> "elastic" </string>
- <real> 210 </real>
- <real> 236 </real>
- <string> "cubic" </string>
- <real> 240 </real>
- <real> 266 </real>
- <string> "circ" </string>
- <real> 270 </real>
- <real> 296 </real>
- <string> "bounce" </string>
- <real> 300 </real>
- <real> 326 </real>
- <string> "back" </string>
- <real> 152 </real>
- <real> 215 </real>
- <real> 372 </real>
- <dictionary shared="false">
- <string> "_editor_collapsed" </string>
- <bool> True </bool>
- </dictionary>
- <real> 63 </real>
- <string> "in" </string>
- <string> "out" </string>
- <string> "in_out" </string>
- <string> "out_in" </string>
- <real> 317 </real>
- <real> 492 </real>
- <dictionary shared="false">
- <string> "_editor_collapsed" </string>
- <bool> True </bool>
- </dictionary>
- <real> 77 </real>
- <string> "move" </string>
- <string> "color" </string>
- <string> "scale" </string>
- <string> "rotate" </string>
- <string> "callback" </string>
- <string> "follow" </string>
- <string> "repeat" </string>
- <string> "pause" </string>
- <real> 384 </real>
- <real> 760 </real>
- <real> 592 </real>
- <dictionary shared="false">
- <string> "_editor_collapsed" </string>
- <bool> True </bool>
- </dictionary>
- <real> 376 </real>
- <real> 19 </real>
- <string> "Color From:" </string>
- <int> 0 </int>
- <real> -1 </real>
- <real> 23 </real>
- <real> 174 </real>
- <real> 178 </real>
- <real> 197 </real>
- <string> "Color To:" </string>
- <real> 201 </real>
- <real> 352 </real>
- <real> 32 </real>
- <real> 768 </real>
- <real> 216 </real>
- <real> 24 </real>
- <real> 552 </real>
- <real> 160 </real>
- <string> "" </string>
- <int> 4 </int>
- <vector2> 0, 0 </vector2>
- <resource resource_type="Texture" path="res://icon.png"> </resource>
- <color> 1, 1, 1, 1 </color>
- <rect2> 0, 0, 0, 0 </rect2>
- <vector2> 0, 184 </vector2>
- <vector2> 736, 0 </vector2>
- <real> 40 </real>
- <real> 224 </real>
- <real> 100 </real>
- </array>
- <string> "nodes" </string>
- <int_array len="2229"> -1, -1, 1, 0, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 20, 9, 21, 10, 0, 0, 0, 23, 22, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 11, 25, 12, 7, 13, 8, 14, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 15, 0, 1, 0, 27, 26, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 16, 8, 17, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 18, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 37, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 21, 7, 16, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 22, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 38, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 23, 7, 16, 8, 24, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 25, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 39, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 26, 7, 16, 8, 27, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 28, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 40, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 29, 7, 16, 8, 30, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 31, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 41, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 32, 7, 16, 8, 33, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 34, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 42, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 35, 7, 16, 8, 36, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 37, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 43, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 38, 7, 16, 8, 39, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 40, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 44, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 41, 7, 16, 8, 42, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 43, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 45, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 44, 7, 16, 8, 45, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 46, 33, 19, 34, 3, 35, 3, 36, 20, 0, 1, 0, 27, 46, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 47, 7, 16, 8, 48, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 49, 33, 19, 34, 3, 35, 3, 36, 20, 0, 0, 0, 23, 47, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 50, 25, 12, 7, 51, 8, 52, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 53, 0, 13, 0, 27, 48, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 54, 8, 17, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 55, 33, 19, 34, 3, 35, 3, 36, 20, 0, 13, 0, 27, 49, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 21, 7, 54, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 56, 33, 19, 34, 3, 35, 3, 36, 20, 0, 13, 0, 27, 50, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 23, 7, 54, 8, 24, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 57, 33, 19, 34, 3, 35, 3, 36, 20, 0, 13, 0, 27, 51, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 26, 7, 54, 8, 27, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 58, 33, 19, 34, 3, 35, 3, 36, 20, 0, 0, 0, 23, 52, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 41, 25, 12, 7, 59, 8, 60, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 61, 0, 18, 0, 27, 53, -1, 27, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 62, 8, 17, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 63, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 54, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 21, 7, 62, 8, 11, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 64, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 55, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 23, 7, 62, 8, 24, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 65, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 56, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 26, 7, 62, 8, 27, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 66, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 57, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 29, 7, 62, 8, 30, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 67, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 58, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 32, 7, 62, 8, 33, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 68, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 59, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 35, 7, 62, 8, 36, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 69, 33, 19, 34, 3, 35, 3, 36, 20, 0, 18, 0, 27, 60, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 38, 7, 62, 8, 39, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 28, 3, 29, 3, 30, 1, 31, 3, 32, 70, 33, 19, 34, 3, 35, 3, 36, 20, 0, 0, 0, 23, 54, -1, 21, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 71, 25, 41, 7, 72, 8, 73, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 21, 74, 0, 27, 0, 62, 61, -1, 30, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 7, 75, 8, 76, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 77, 36, 78, 70, 78, 71, 3, 72, 3, 73, 79, 0, 27, 0, 75, 74, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 80, 7, 75, 8, 81, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 27, 0, 62, 76, -1, 31, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 82, 7, 75, 8, 83, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 1, 16, 1, 17, 8, 19, 2, 63, 6, 64, 2, 65, 2, 66, 2, 67, 6, 68, 3, 69, 3, 32, 84, 36, 78, 70, 78, 71, 3, 72, 3, 73, 79, 0, 27, 0, 75, 77, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 25, 85, 7, 75, 8, 86, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 3, 17, 8, 18, 8, 19, 2, 0, 0, 0, 79, 78, -1, 5, 2, 0, 80, 20, 81, 1, 82, 1, 83, 2, 0, 32, 0, 85, 84, -1, 20, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 87, 25, 87, 7, 88, 8, 89, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 18, 8, 19, 2, 0, 33, 0, 87, 86, -1, 24, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 33, 25, 90, 7, 91, 8, 92, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 32, 93, 88, 1, 89, 1, 90, 94, 91, 3, 0, 33, 0, 93, 92, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 94, 95, 9, 6, 10, 7, 95, 96, 96, 1, 97, 95, 98, 3, 99, 3, 100, 20, 101, 20, 102, 78, 103, 97, 104, 3, 105, 98, 0, 33, 0, 93, 58, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 94, 99, 9, 6, 10, 7, 95, 96, 96, 1, 97, 95, 98, 3, 99, 3, 100, 20, 101, 20, 102, 78, 103, 97, 104, 3, 105, 98, 0, 33, 0, 93, 106, -1, 19, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 94, 100, 9, 6, 10, 7, 95, 96, 96, 1, 97, 95, 98, 3, 99, 3, 100, 20, 101, 20, 102, 78, 103, 97, 104, 3, 105, 98, 0, 0, 0, 108, 107, -1, 28, 2, 0, 3, 1, 4, 2, 5, 2, 6, 3, 24, 101, 25, 102, 7, 72, 8, 41, 9, 6, 10, 7, 11, 0, 12, 0, 13, 0, 14, 0, 15, 3, 16, 1, 17, 8, 19, 2, 63, 6, 64, 103, 65, 2, 66, 6, 67, 2, 68, 3, 69, 3, 109, 78, 110, 3, 0 </int_array>
- <string> "conns" </string>
- <int_array len="12"> 32, 0, 112, 111, 2, 0, 38, 0, 114, 113, 2, 0 </int_array>
- </dictionary>
-
- </main_resource>
-</resource_file>
diff --git a/demos/misc/udp_chat/chat.gd b/demos/misc/udp_chat/chat.gd
index 3270eebbfe..b60afa9ded 100644
--- a/demos/misc/udp_chat/chat.gd
+++ b/demos/misc/udp_chat/chat.gd
@@ -1,72 +1,66 @@
extends Panel
-# Really simple UDP chat client, not intended as a chat example!!
+# Really simple UDP chat client, not intended as a comprehensive chat implementation.
# (UDP can lose packets and you won't normally find out, so don't do a chat this way)
# This is just a demo that shows how to use the UDP class.
+# Member variables
var udp = PacketPeerUDP.new()
-func _process(delta):
+func _process(delta):
if (not udp.is_listening()):
return
-
- while(udp.get_available_packet_count()>0):
+
+ while(udp.get_available_packet_count() > 0):
var packet = udp.get_var()
- if (typeof(packet)==TYPE_STRING):
+ if (typeof(packet) == TYPE_STRING):
var host = udp.get_packet_ip()
var port = udp.get_packet_port()
- get_node("chat/text").add_text("("+host+":"+str(port)+":) "+packet)
+ get_node("chat/text").add_text("(" + host + ":" + str(port) + ":) " + packet)
get_node("chat/text").newline()
-
-
+
func _ready():
- # Initalization here
- get_node("chat").add_style_override("panel",get_stylebox("bg","Tree"))
+ get_node("chat").add_style_override("panel", get_stylebox("bg", "Tree"))
set_process(true)
-
func send_message(text):
if (udp.is_listening()):
udp.put_var(text)
-
-
-func _on_connect_toggled( pressed ):
+func _on_connect_toggled(pressed):
if (pressed):
- var err = udp.listen( get_node("listen_port").get_val() )
- if (err!=OK):
- get_node("status").set_text("Error:\nCan't Listen.")
+ var err = udp.listen(get_node("listen_port").get_val())
+ if (err != OK):
+ get_node("status").set_text("Error:\nCan't listen.")
get_node("connect").set_pressed(false)
else:
get_node("status").set_text("Connected.")
get_node("connect").set_text("Disconnect")
err = udp.set_send_address(get_node("remote_host").get_text(),get_node("remote_port").get_val())
- if (err!=OK):
- get_node("status").set_text("Error:\nCan't Resolve.")
+ if (err != OK):
+ get_node("status").set_text("Error:\nCan't resolve.")
get_node("connect").set_pressed(false)
else:
- send_message("* "+get_node("user_name").get_text()+" entered chat.")
+ send_message("* " + get_node("user_name").get_text() + " entered chat.")
else:
-
udp.close()
get_node("status").set_text("Disconnected.")
get_node("connect").set_text("Connect")
-
+func _on_entry_line_text_entered(text):
+ _on_entry_button_pressed()
-func _on_entry_line_text_entered( text ):
- _on_entry_button_pressed();
func _on_entry_button_pressed():
var msg = get_node("entry_line").get_text()
- if (msg==""):
+ if (msg == ""):
return
- send_message(get_node("user_name").get_text()+"> "+msg)
+ send_message(get_node("user_name").get_text() + "> " + msg)
get_node("entry_line").set_text("")
diff --git a/demos/misc/udp_chat/chat.scn b/demos/misc/udp_chat/chat.scn
index efa4b799a0..fe38e9da72 100644
--- a/demos/misc/udp_chat/chat.scn
+++ b/demos/misc/udp_chat/chat.scn
Binary files differ
diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd
index 1609dda699..cd8e0e185b 100644
--- a/demos/misc/window_management/control.gd
+++ b/demos/misc/window_management/control.gd
@@ -1,17 +1,18 @@
extends Control
+# Member variables
var mousepos
-func _fixed_process(delta):
+func _fixed_process(delta):
var modetext = "Mode:\n"
if(OS.is_window_fullscreen()):
modetext += "Fullscreen\n"
else:
modetext += "Windowed\n"
-
+
if(!OS.is_window_resizable()):
modetext += "FixedSize\n"
@@ -29,119 +30,119 @@ func _fixed_process(delta):
get_node("Label_Mode").set_text(modetext)
- get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) )
+ get_node("Label_Position").set_text(str("Position:\n", OS.get_window_position()))
- get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) )
+ get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size()))
- get_node("Label_MousePosition").set_text(str("Mouse Position:\n", mousepos ) )
+ get_node("Label_MousePosition").set_text(str("Mouse Position:\n", mousepos))
- get_node("Label_Screen_Count").set_text( str("Screen_Count:\n", OS.get_screen_count() ) )
+ get_node("Label_Screen_Count").set_text(str("Screen_Count:\n", OS.get_screen_count()))
- get_node("Label_Screen_Current").set_text( str("Screen:\n", OS.get_current_screen() ) )
+ get_node("Label_Screen_Current").set_text(str("Screen:\n", OS.get_current_screen()))
- get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) )
+ get_node("Label_Screen0_Resolution").set_text(str("Screen0 Resolution:\n", OS.get_screen_size()))
- get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position() ) )
+ get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n", OS.get_screen_position()))
if(OS.get_screen_count() > 1):
get_node("Button_Screen0").show()
get_node("Button_Screen1").show()
get_node("Label_Screen1_Resolution").show()
get_node("Label_Screen1_Position").show()
- get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) )
- get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) )
+ get_node("Label_Screen1_Resolution").set_text(str("Screen1 Resolution:\n", OS.get_screen_size(1)))
+ get_node("Label_Screen1_Position").set_text(str("Screen1 Position:\n", OS.get_screen_position(1)))
else:
get_node("Button_Screen0").hide()
get_node("Button_Screen1").hide()
get_node("Label_Screen1_Resolution").hide()
get_node("Label_Screen1_Position").hide()
-
- get_node("Button_Fullscreen").set_pressed( OS.is_window_fullscreen() )
- get_node("Button_FixedSize").set_pressed( !OS.is_window_resizable() )
- get_node("Button_Minimized").set_pressed( OS.is_window_minimized() )
- get_node("Button_Maximized").set_pressed( OS.is_window_maximized() )
- get_node("Button_Mouse_Grab").set_pressed( Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED )
+
+ get_node("Button_Fullscreen").set_pressed(OS.is_window_fullscreen())
+ get_node("Button_FixedSize").set_pressed(!OS.is_window_resizable())
+ get_node("Button_Minimized").set_pressed(OS.is_window_minimized())
+ get_node("Button_Maximized").set_pressed(OS.is_window_maximized())
+ get_node("Button_Mouse_Grab").set_pressed(Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED)
func check_wm_api():
var s = ""
- if( !OS.has_method("get_screen_count") ):
+ if(!OS.has_method("get_screen_count")):
s += " - get_screen_count()\n"
- if( !OS.has_method("get_current_screen") ):
+ if(!OS.has_method("get_current_screen")):
s += " - get_current_screen()\n"
- if( !OS.has_method("set_current_screen") ):
+ if(!OS.has_method("set_current_screen")):
s += " - set_current_screen()\n"
- if( !OS.has_method("get_screen_position") ):
+ if(!OS.has_method("get_screen_position")):
s += " - get_screen_position()\n"
- if( !OS.has_method("get_screen_size") ):
+ if(!OS.has_method("get_screen_size")):
s += " - get_screen_size()\n"
- if( !OS.has_method("get_window_position") ):
+ if(!OS.has_method("get_window_position")):
s += " - get_window_position()\n"
- if( !OS.has_method("set_window_position") ):
+ if(!OS.has_method("set_window_position")):
s += " - set_window_position()\n"
- if( !OS.has_method("get_window_size") ):
+ if(!OS.has_method("get_window_size")):
s += " - get_window_size()\n"
- if( !OS.has_method("set_window_size") ):
+ if(!OS.has_method("set_window_size")):
s += " - set_window_size()\n"
- if( !OS.has_method("set_window_fullscreen") ):
+ if(!OS.has_method("set_window_fullscreen")):
s += " - set_window_fullscreen()\n"
- if( !OS.has_method("is_window_fullscreen") ):
+ if(!OS.has_method("is_window_fullscreen")):
s += " - is_window_fullscreen()\n"
- if( !OS.has_method("set_window_resizable") ):
+ if(!OS.has_method("set_window_resizable")):
s += " - set_window_resizable()\n"
- if( !OS.has_method("is_window_resizable") ):
+ if(!OS.has_method("is_window_resizable")):
s += " - is_window_resizable()\n"
- if( !OS.has_method("set_window_minimized") ):
+ if(!OS.has_method("set_window_minimized")):
s += " - set_window_minimized()\n"
- if( !OS.has_method("is_window_minimized") ):
+ if(!OS.has_method("is_window_minimized")):
s += " - is_window_minimized()\n"
- if( !OS.has_method("set_window_maximized") ):
+ if(!OS.has_method("set_window_maximized")):
s += " - set_window_maximized()\n"
- if( !OS.has_method("is_window_maximized") ):
+ if(!OS.has_method("is_window_maximized")):
s += " - is_window_maximized()\n"
- if( s.length() == 0 ):
+ if(s.length() == 0):
return true
else:
var text = get_node("ImplementationDialog/Text").get_text()
- get_node("ImplementationDialog/Text").set_text( text + s )
+ get_node("ImplementationDialog/Text").set_text(text + s)
get_node("ImplementationDialog").show()
return false
func _ready():
- if( check_wm_api() ):
+ if(check_wm_api()):
set_fixed_process(true)
set_process_input(true)
-func _input(ev):
- if (ev.type==InputEvent.MOUSE_MOTION):
- mousepos = ev.pos
+func _input(event):
+ if (event.type == InputEvent.MOUSE_MOTION):
+ mousepos = event.pos
func _on_Button_MoveTo_pressed():
- OS.set_window_position( Vector2(100,100) )
+ OS.set_window_position(Vector2(100, 100))
func _on_Button_Resize_pressed():
- OS.set_window_size( Vector2(1024,768) )
+ OS.set_window_size(Vector2(1024, 768))
func _on_Button_Screen0_pressed():
diff --git a/demos/misc/window_management/observer/observer.gd b/demos/misc/window_management/observer/observer.gd
index d27912a670..f100811859 100644
--- a/demos/misc/window_management/observer/observer.gd
+++ b/demos/misc/window_management/observer/observer.gd
@@ -1,16 +1,17 @@
extends Spatial
+# Member variables
var r_pos = Vector2()
var state
-const STATE_MENU=0
-const STATE_GRAB=1
+const STATE_MENU = 0
+const STATE_GRAB = 1
+
func direction(vector):
- var v = get_node("Camera").get_global_transform().basis * vector
+ var v = get_node("Camera").get_global_transform().basis*vector
v = v.normalized()
-
return v
@@ -22,43 +23,42 @@ func impulse(event, action):
func _fixed_process(delta):
-
if(state != STATE_GRAB):
return
if(Input.get_mouse_mode() != Input.MOUSE_MODE_CAPTURED):
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
- var dir = Vector3()
+ var dir = Vector3()
var cam = get_global_transform()
var org = get_translation()
if (Input.is_action_pressed("move_forward")):
- dir += direction(Vector3(0,0,-1))
+ dir += direction(Vector3(0, 0, -1))
if (Input.is_action_pressed("move_backwards")):
- dir += direction(Vector3(0,0,1))
+ dir += direction(Vector3(0, 0, 1))
if (Input.is_action_pressed("move_left")):
- dir += direction(Vector3(-1,0,0))
+ dir += direction(Vector3(-1, 0, 0))
if (Input.is_action_pressed("move_right")):
- dir += direction(Vector3(1,0,0))
+ dir += direction(Vector3(1, 0, 0))
dir = dir.normalized()
- move(dir * 10 * delta)
- var d = delta * 0.1
+ move(dir*10*delta)
+ var d = delta*0.1
- var yaw = get_transform().rotated(Vector3(0,1,0), d * r_pos.x)
+ var yaw = get_transform().rotated(Vector3(0, 1, 0), d*r_pos.x)
set_transform(yaw)
var cam = get_node("Camera")
- var pitch = cam.get_transform().rotated(Vector3(1,0,0), d * r_pos.y)
+ var pitch = cam.get_transform().rotated(Vector3(1, 0, 0), d*r_pos.y)
cam.set_transform(pitch)
r_pos.x = 0.0
r_pos.y = 0.0
-func _input( event ):
+func _input(event):
if(event.type == InputEvent.MOUSE_MOTION):
r_pos = event.relative_pos
@@ -76,4 +76,3 @@ func _ready():
set_process_input(true)
state = STATE_MENU
-
diff --git a/demos/misc/window_management/observer/observer.scn b/demos/misc/window_management/observer/observer.scn
index da29ad62b8..813d7d4587 100644
--- a/demos/misc/window_management/observer/observer.scn
+++ b/demos/misc/window_management/observer/observer.scn
Binary files differ
diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn
index 8db43b6638..35662871f1 100644
--- a/demos/misc/window_management/window_management.scn
+++ b/demos/misc/window_management/window_management.scn
Binary files differ