init
This commit is contained in:
30
Scripts/NPCMayor.gd
Normal file
30
Scripts/NPCMayor.gd
Normal file
@@ -0,0 +1,30 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
signal interaction_happened(text)
|
||||
|
||||
@export var npc_name: String = "Mayor"
|
||||
@export var dialogue: String = "欢迎来到WhaleTown,我是镇长范鲸鱼"
|
||||
|
||||
func _ready():
|
||||
$Sprite2D.texture = preload("res://Assets/MayorWhale.png")
|
||||
# Sprite Sheet setup for idle animation (if needed later)
|
||||
# For now, frame 0 is fine
|
||||
$Sprite2D.hframes = 3
|
||||
$Sprite2D.vframes = 4
|
||||
|
||||
# Start Idle Animation
|
||||
if has_node("AnimationPlayer"):
|
||||
$AnimationPlayer.play("idle")
|
||||
|
||||
# Ensure interaction layer
|
||||
collision_layer = 3 # Layer 1 & 2 (Blocking)
|
||||
collision_mask = 3
|
||||
|
||||
func interact():
|
||||
show_bubble(dialogue)
|
||||
return null
|
||||
|
||||
func show_bubble(text):
|
||||
var bubble = preload("res://Scenes/UI/ChatBubble.tscn").instantiate()
|
||||
add_child(bubble)
|
||||
bubble.set_text(text)
|
||||
Reference in New Issue
Block a user