feat: started adding animation behaviour
This commit is contained in:
parent
2f60fd19d6
commit
2a9e824a9e
12 changed files with 123 additions and 93 deletions
|
@ -2,10 +2,10 @@ extends Node2D
|
|||
class_name DragonSprite
|
||||
|
||||
|
||||
@export var hat: Sprite2D
|
||||
@export var shirt: Sprite2D
|
||||
@export var decor: Sprite2D
|
||||
@export var color: Sprite2D
|
||||
@export var hat: AnimatedSprite2D
|
||||
@export var shirt: AnimatedSprite2D
|
||||
@export var decor: AnimatedSprite2D
|
||||
@export var color: AnimatedSprite2D
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
|
@ -14,10 +14,19 @@ class_name DragonSprite
|
|||
|
||||
|
||||
func dress(properties: DragonProperties):
|
||||
self.hat.texture = hat_outfits.get_texture(properties.hat)
|
||||
self.shirt.texture = shirt_outfits.get_texture(properties.shirt)
|
||||
self.decor.texture = decor_outfits.get_texture(properties.decor)
|
||||
self.color.texture = color_outfits.get_texture(properties.color)
|
||||
_set_dress(hat, hat_outfits.get_texture(properties.hat))
|
||||
_set_dress(shirt, shirt_outfits.get_texture(properties.shirt))
|
||||
_set_dress(decor, decor_outfits.get_texture(properties.decor))
|
||||
_set_dress(color, color_outfits.get_texture(properties.color))
|
||||
play_idle()
|
||||
|
||||
|
||||
func _set_dress(part: AnimatedSprite2D, dress: SpriteFrames):
|
||||
if dress == null:
|
||||
part.visible = false
|
||||
else:
|
||||
part.visible = true
|
||||
part.set_sprite_frames(dress)
|
||||
|
||||
|
||||
func walk_left():
|
||||
|
@ -28,3 +37,30 @@ func walk_left():
|
|||
func walk_right():
|
||||
$Sprite.scale.x = -1
|
||||
$DragonBody.scale.x = -1
|
||||
|
||||
|
||||
func _play_animation(animation_name: String, part: AnimatedSprite2D) -> void:
|
||||
if !part.is_visible():
|
||||
return
|
||||
part.play(animation_name)
|
||||
|
||||
|
||||
func play_idle() -> void:
|
||||
_play_animation("idle", hat)
|
||||
_play_animation("idle", shirt)
|
||||
_play_animation("idle", decor)
|
||||
_play_animation("idle", color)
|
||||
|
||||
|
||||
func play_fly() -> void:
|
||||
_play_animation("fly", hat)
|
||||
_play_animation("fly", shirt)
|
||||
_play_animation("fly", decor)
|
||||
_play_animation("fly", color)
|
||||
|
||||
|
||||
func play_walk() -> void:
|
||||
_play_animation("walk", hat)
|
||||
_play_animation("walk", shirt)
|
||||
_play_animation("walk", decor)
|
||||
_play_animation("walk", color)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue