2023-07-25 14:21:10 +09:30
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
enum Battle_Frame {
|
|
|
|
STAND,
|
|
|
|
GUARD,
|
|
|
|
WALK,
|
|
|
|
DOWN,
|
|
|
|
R_SWING,
|
|
|
|
L_SWING2,
|
|
|
|
L_SWING,
|
|
|
|
CHEER,
|
|
|
|
RECOIL,
|
|
|
|
CHANT1,
|
|
|
|
CHANT2,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum Battle_Anim {
|
|
|
|
STAND,
|
|
|
|
GUARD,
|
|
|
|
WALK,
|
|
|
|
DOWN,
|
|
|
|
R_SWING,
|
|
|
|
L_SWING,
|
|
|
|
CHEER,
|
|
|
|
RECOIL,
|
|
|
|
CHANT
|
|
|
|
}
|
|
|
|
|
|
|
|
var texture: Texture
|
|
|
|
var animation = Battle_Anim.STAND # Battle_Anim enums aren't real types in GDscript :/
|
|
|
|
|
|
|
|
const Animation_Frames = {
|
|
|
|
Battle_Anim.STAND: [Battle_Frame.STAND],
|
|
|
|
Battle_Anim.GUARD: [Battle_Frame.GUARD],
|
|
|
|
Battle_Anim.WALK: [Battle_Frame.WALK, Battle_Frame.STAND],
|
|
|
|
Battle_Anim.DOWN: [Battle_Frame.DOWN],
|
|
|
|
Battle_Anim.R_SWING: [Battle_Frame.R_SWING, Battle_Frame.WALK],
|
|
|
|
Battle_Anim.L_SWING: [Battle_Frame.L_SWING, Battle_Frame.L_SWING2],
|
|
|
|
Battle_Anim.CHEER: [Battle_Frame.CHEER, Battle_Frame.STAND],
|
|
|
|
Battle_Anim.RECOIL: [Battle_Frame.RECOIL],
|
|
|
|
Battle_Anim.CHANT: [Battle_Frame.CHANT1, Battle_Frame.CHANT2]
|
|
|
|
}
|
|
|
|
|
|
|
|
func _init():
|
2023-07-25 16:33:45 +09:30
|
|
|
material = SpriteLoader.shader_material.duplicate()
|
2023-07-25 14:21:10 +09:30
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(_delta):
|
|
|
|
update()
|
|
|
|
# pass
|
|
|
|
|
|
|
|
func _draw():
|
2023-08-04 18:17:08 +09:30
|
|
|
if self.texture == null:
|
|
|
|
return
|
2023-07-25 14:21:10 +09:30
|
|
|
var frames = Animation_Frames[animation]
|
|
|
|
var frame = frames[int(globals.time*4) % len(frames)]
|
|
|
|
var y = 0
|
|
|
|
if frame == Battle_Frame.CHEER:
|
|
|
|
y -= 1
|
|
|
|
#draw_texture(texture, Vector2(0, 0))
|
|
|
|
draw_texture_rect_region(texture, Rect2(0, y, 16, 24), Rect2(0, 24*frame, 16, 24))
|