diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-05-16 17:05:56 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-05-16 17:05:56 -0300 |
commit | 1e382dbb1835d0509630ee9e6a61501e3839239b (patch) | |
tree | a5a915045d1c02e321a33cbcaf6e9be1c7af929f /demos | |
parent | 27cb75112ed3a6b98a1edfefe3c419fbe20d6337 (diff) |
-small motion demo, to better troubleshoot
Diffstat (limited to 'demos')
-rw-r--r-- | demos/2d/motion/car.png | bin | 0 -> 2086 bytes | |||
-rw-r--r-- | demos/2d/motion/engine.cfg | 4 | ||||
-rw-r--r-- | demos/2d/motion/motion.gd | 38 | ||||
-rw-r--r-- | demos/2d/motion/motion.scn | bin | 0 -> 2845 bytes |
4 files changed, 42 insertions, 0 deletions
diff --git a/demos/2d/motion/car.png b/demos/2d/motion/car.png Binary files differnew file mode 100644 index 0000000000..7ea973ceeb --- /dev/null +++ b/demos/2d/motion/car.png diff --git a/demos/2d/motion/engine.cfg b/demos/2d/motion/engine.cfg new file mode 100644 index 0000000000..064de6b331 --- /dev/null +++ b/demos/2d/motion/engine.cfg @@ -0,0 +1,4 @@ +[application] + +name="Motion Test" +main_scene="res://motion.scn" diff --git a/demos/2d/motion/motion.gd b/demos/2d/motion/motion.gd new file mode 100644 index 0000000000..8f8f56a889 --- /dev/null +++ b/demos/2d/motion/motion.gd @@ -0,0 +1,38 @@ + +extends Sprite + + +export var use_idle=true + +# member variables here, example: +# var a=2 +# var b="textvar" +const BEGIN = -113 +const END = 907 +const TIME = 5.0 # seconds +const SPEED = (END-BEGIN)/TIME + +func _process(delta): + var ofs = get_pos() + ofs.x+=delta*SPEED + if (ofs.x>END): + ofs.x=BEGIN + set_pos(ofs) + +func _fixed_process(delta): + var ofs = get_pos() + ofs.x+=delta*SPEED + if (ofs.x>END): + ofs.x=BEGIN + set_pos(ofs) + + +func _ready(): + # Initialization here + if (use_idle): + set_process(true) + else: + set_fixed_process(true) + pass + + diff --git a/demos/2d/motion/motion.scn b/demos/2d/motion/motion.scn Binary files differnew file mode 100644 index 0000000000..6c5b5307ac --- /dev/null +++ b/demos/2d/motion/motion.scn |