summaryrefslogtreecommitdiff
path: root/demos/2d/platformer/moving_platform.gd
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-02-09 22:10:30 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-02-09 22:10:30 -0300
commit0b806ee0fc9097fa7bda7ac0109191c9c5e0a1ac (patch)
tree276c4d099e178eb67fbd14f61d77b05e3808e9e3 /demos/2d/platformer/moving_platform.gd
parent0e49da1687bc8192ed210947da52c9e5c5f301bb (diff)
GODOT IS OPEN SOURCE
Diffstat (limited to 'demos/2d/platformer/moving_platform.gd')
-rw-r--r--demos/2d/platformer/moving_platform.gd27
1 files changed, 27 insertions, 0 deletions
diff --git a/demos/2d/platformer/moving_platform.gd b/demos/2d/platformer/moving_platform.gd
new file mode 100644
index 0000000000..719d9e460e
--- /dev/null
+++ b/demos/2d/platformer/moving_platform.gd
@@ -0,0 +1,27 @@
+
+extends Node2D
+
+# member variables here, example:
+# var a=2
+# var b="textvar"
+
+export var motion = Vector2()
+export var cycle = 1.0
+var accum=0.0
+
+func _fixed_process(delta):
+
+ accum += delta * (1.0/cycle) * PI * 2.0
+ accum = fmod(accum,PI*2.0)
+ var d = sin(accum)
+ var xf = Matrix32()
+ xf[2]= motion * d
+ get_node("platform").set_transform(xf)
+
+
+func _ready():
+ # Initalization here
+ set_fixed_process(true)
+ pass
+
+