forked from team-sg/hero-mark-2
STG-2600 redraw
This commit is contained in:
parent
d215a8728a
commit
d87ff6531c
34 changed files with 584 additions and 203 deletions
41
scripts/sprite_ext.gd
Normal file
41
scripts/sprite_ext.gd
Normal file
|
@ -0,0 +1,41 @@
|
|||
extends Sprite
|
||||
|
||||
|
||||
## emitted when the stop frame is reached
|
||||
signal stopped()
|
||||
|
||||
|
||||
## speed at which to animate
|
||||
export var fps: float = 0.0
|
||||
## frame to stop on when reached
|
||||
export var stop_at_frame: int = -1
|
||||
## whether to animate back and forth instead of loop
|
||||
export var ping_pong: bool = false
|
||||
## whether to maintain fixed global rotation
|
||||
export var rotation_lock: float = NAN
|
||||
|
||||
|
||||
## whether the animation is paused
|
||||
var stopped: bool = false
|
||||
|
||||
|
||||
var _time: float = 0.0
|
||||
|
||||
|
||||
func _process(delta):
|
||||
# rotation lock
|
||||
if not is_nan(rotation_lock):
|
||||
global_rotation_degrees = rotation_lock
|
||||
# do not animate if paused
|
||||
if stopped:
|
||||
return
|
||||
# accumulate time and animate
|
||||
_time += abs(fps) * delta
|
||||
if _time >= 1.0:
|
||||
_time -= 1.0
|
||||
# posmod to loop around
|
||||
frame = posmod(frame + int(sign(fps)), hframes * vframes)
|
||||
if frame == stop_at_frame:
|
||||
stopped = true
|
||||
if ping_pong and frame == 0:
|
||||
fps = -fps
|
Loading…
Add table
Add a link
Reference in a new issue