20 lines
488 B
GDScript
20 lines
488 B
GDScript
extends Area2D
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
# Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
pass
|
|
@export var value: int = 1 # 这枚金币值多少分
|
|
|
|
func _ready():
|
|
body_entered.connect(_on_body_entered)
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.has_method("add_coin"): # 确认是主角
|
|
body.add_coin(value)
|
|
queue_free()
|