9dffacd938
Player: move/jump (Space), test flight (F, debug builds only). Key: pickup, hold S to aim with live trajectory preview, release to throw, W to warp to the thrown key. Spring bounce. Spikes deal damage. 3-heart health, Z consumes a heal item for +1 heart and a 5s shield. HUD with hearts and item count. Death screen with fade-to-black and restart. Hidden passages. Assets: Kenney Pixel Platformer (CC0).
15 lines
361 B
GDScript
15 lines
361 B
GDScript
extends Area2D
|
|
|
|
## 走到就捡走,给玩家增加一次"回血道具"。
|
|
## 碰撞掩码已经限制成只检测玩家那一层,所以进到这里的一定是玩家。
|
|
|
|
|
|
func _ready() -> void:
|
|
body_entered.connect(_on_body_entered)
|
|
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.has_method("add_heal_item"):
|
|
body.add_heal_item()
|
|
queue_free()
|