-small motion demo, to better troubleshoot
This commit is contained in:
parent
27cb75112e
commit
1e382dbb18
4 changed files with 42 additions and 0 deletions
BIN
demos/2d/motion/car.png
Normal file
BIN
demos/2d/motion/car.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
4
demos/2d/motion/engine.cfg
Normal file
4
demos/2d/motion/engine.cfg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[application]
|
||||||
|
|
||||||
|
name="Motion Test"
|
||||||
|
main_scene="res://motion.scn"
|
38
demos/2d/motion/motion.gd
Normal file
38
demos/2d/motion/motion.gd
Normal file
|
@ -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
|
||||||
|
|
||||||
|
|
BIN
demos/2d/motion/motion.scn
Normal file
BIN
demos/2d/motion/motion.scn
Normal file
Binary file not shown.
Loading…
Reference in a new issue