summaryrefslogtreecommitdiff
path: root/demos/2d/motion/motion.gd
blob: f9bbd6f90d8719050a7d552eedfa6bb7a48387db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

extends Sprite

# Member variables
const BEGIN = -113
const END = 907
const TIME = 5.0 # Seconds
const SPEED = (END - BEGIN)/TIME

export var use_idle = true


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():
	if (use_idle):
		set_process(true)
	else:
		set_fixed_process(true)