Files
GGJ26/scenes/character/character.gd
minimata 59b63b0945
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 7s
Create tag and build when new code gets to main / Export (push) Successful in 1m19s
guest review process
2026-01-31 15:10:06 +01:00

58 lines
1.3 KiB
GDScript

@tool
extends Node2D
class_name Character
@export var chara_resource: CharacterResource:
set(new_resource):
chara_resource = new_resource
_on_chara_resource_changed()
@onready var face: Sprite2D = $Face
@onready var mask_eyes: Mask = $MaskEyes
@onready var mask_mouth: Mask = $MaskMouth
@onready var animation_player: AnimationPlayer = $AnimationPlayer
func _on_chara_resource_changed() -> void:
if chara_resource == null:
return
if face != null:
face.texture = chara_resource.chara_sprite
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if Engine.is_editor_hint():
_engine_process(delta)
else:
_game_process(delta)
func _game_process(delta: float) -> void:
pass
func _engine_process(delta: float) -> void:
if chara_resource == null:
return
mask_eyes.position = chara_resource.mask_eyes_position
mask_eyes.rotation = chara_resource.mask_eyes_rotation
mask_mouth.position = chara_resource.mask_mouth_position
mask_mouth.rotation = chara_resource.mask_mouth_rotation
func come_in() -> void:
print("come ine")
animation_player.play("come_in")
func go_out() -> void:
animation_player.play("go_out")