godot-game-loop-collection
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCollection Game Loops
收集游戏循环
Overview
概述
This skill provides a standardized framework for "Collection Loops" – gameplay objectives where the player must find and gather a specific set of items (e.g., hidden eggs, data logs, coins).
本Skill为“收集循环”提供了标准化框架——这类玩法目标要求玩家寻找并收集一组特定物品(例如:隐藏彩蛋、数据日志、金币)。
Core Components
核心组件
1. Collection Manager (collection_manager.gd
)
collection_manager.gd1. 收集管理器(collection_manager.gd
)
collection_manager.gdThe central brain of the hunt.
- Role: Tracks progress ().
current / target - Behavior: Listens for -> Updates items -> Signals
item_collected(id)on valid count.collection_completed - Tip: Use strings to run multiple hunts simultaneously (e.g., "red_eggs" vs "blue_eggs").
collection_id
寻宝系统的核心大脑。
- 作用:追踪进度()。
当前数量/目标数量 - 行为:监听信号 -> 更新物品状态 -> 当数量达标时发送
item_collected(id)信号。collection_completed - 提示:使用字符串可同时运行多个寻宝任务(例如:“red_eggs”与“blue_eggs”)。
collection_id
2. Collectible Item (collectible_item.gd
)
collectible_item.gd2. 可收集物品(collectible_item.gd
)
collectible_item.gdThe physical object in the world.
- Role: Handles interaction and self-destruction.
- Behavior: On Interact -> Play VFX -> Emit Signal -> Queue Free.
游戏世界中的实体对象。
- 作用:处理交互与自销毁逻辑。
- 行为:当触发交互时 -> 播放视觉特效(VFX) -> 发送信号 -> 调用Queue Free销毁自身。
3. Hidden Item Spawner (hidden_item_spawner.gd
)
hidden_item_spawner.gd3. 隐藏物品生成器(hidden_item_spawner.gd
)
hidden_item_spawner.gdAutomates the placement of items.
- Role: Populates the level.
- Behavior: Instantiates the item scene at:
- Hand-placed nodes (Deterministic).
Marker3D - Random points within a volume (Procedural).
CollisionShape
- Hand-placed
自动放置物品的工具。
- 作用:填充关卡内容。
- 行为:在以下位置实例化物品场景:
- 手动放置的节点(确定性生成)。
Marker3D - 体积内的随机点(程序化生成)。
CollisionShape
- 手动放置的
Usage Example
使用示例
gdscript
undefinedgdscript
undefinedIn a Level Script or Game Mode
In a Level Script or Game Mode
@onready var manager = $CollectionManager
func _ready():
manager.start_collection("easter_egg_2024", 10)
manager.collection_completed.connect(_on_all_eggs_found)
func _on_all_eggs_found():
print("You found all the eggs! Here is a bunny hat.")
# Unlock reward
undefined@onready var manager = $CollectionManager
func _ready():
manager.start_collection("easter_egg_2024", 10)
manager.collection_completed.connect(_on_all_eggs_found)
func _on_all_eggs_found():
print("You found all the eggs! Here is a bunny hat.")
# Unlock reward
undefinedBest Practices
最佳实践
- Persistence: Combine with to save which specific IDs have been found if the player needs to quit and resume.
godot-mechanic-secrets - NEVER hardcode spawn positions in code: Always use or
Marker3Dnodes in the scene so designers can adjust layout without touching code.CollisionShape3D - Avoid "God Objects": The shouldn't handle input, UI, AND audio. Let it emit signals and let other systems react.
CollectionManager - Juice: Always spawn particles or play a sound before the item disappears. Immediate feels dry.
queue_free()
- 持久化:结合,可保存玩家已找到的特定物品ID,支持玩家退出后继续游戏。
godot-mechanic-secrets - 绝对不要在代码中硬编码生成位置:始终在场景中使用或
Marker3D节点,这样设计师无需修改代码即可调整布局。CollisionShape3D - 避免“上帝对象”:不应同时处理输入、UI和音频。让它发送信号,由其他系统响应即可。
CollectionManager - 增加趣味性(Juice):物品消失前务必生成粒子特效或播放音效。直接调用会让体验显得枯燥。
queue_free()