bullet texture animations
This commit is contained in:
parent
f44f38b58c
commit
3d2fde3381
11 changed files with 160 additions and 18 deletions
19
systems/visuals/animation_strip.gd
Normal file
19
systems/visuals/animation_strip.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class_name AnimationStrip
|
||||
extends Resource
|
||||
|
||||
|
||||
@export var texture: Texture
|
||||
@export var frames: int = 1
|
||||
@export var fps: float = 1.0
|
||||
|
||||
|
||||
func draw(canvas_item: CanvasItem, time: float, modulate: Color = Color.WHITE) -> void:
|
||||
var frame_size = Vector2((texture.get_width() / frames), float(texture.get_height()))
|
||||
var current_frame = fmod(floorf(time * fps), frames)
|
||||
print(time * fps)
|
||||
canvas_item.draw_texture_rect_region(
|
||||
texture,
|
||||
Rect2(-frame_size * 0.5, frame_size),
|
||||
Rect2(Vector2(current_frame * frame_size.x, 0.0), frame_size),
|
||||
modulate
|
||||
)
|
||||
1
systems/visuals/animation_strip.gd.uid
Normal file
1
systems/visuals/animation_strip.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://0ognvvq2ncd7
|
||||
Loading…
Add table
Add a link
Reference in a new issue