godot-gdscript-patterns
它能做什么
这个 AI 代理可以帮你使用 Godot 工具开发游戏。它理解游戏的基本构件(场景、信号),并能帮你以有条理、高效的方式编写代码(GDScript)。
适用场景
- ✓在 Godot 中制作游戏时。
- ✓整理游戏代码时。
- ✓学习 Godot 最佳实践时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/game-development/skills/godot-gdscript-patterns/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我该如何在 Godot 中创建一个能移动和攻击的角色?”
每周 5 个新技能,1 分钟读完。
工作原理
它会通过代码示例和讲解,介绍 Godot 如何组织游戏的各个部分(节点、场景),以及如何编写 GDScript 代码让你的游戏运行起来。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Godot GDScript Patterns
Production patterns for Godot 4.x game development with GDScript, covering architecture, signals, scenes, and optimization.
When to Use This Skill
- Building games with Godot 4
- Implementing game systems in GDScript
- Designing scene architecture
- Managing game state
- Optimizing GDScript performance
- Learning Godot best practices
Core Concepts
1. Godot Architecture
Node: Base building block
├── Scene: Reusable node tree (saved as .tscn)
├── Resource: Data container (saved as .tres)
├── Signal: Event communication
└── Group: Node categorization
2. GDScript Basics
class_name Player
extends CharacterBody2D
# Signals
signal health_changed(new_health: int)
signal died
# Exports (Inspector-editable)
@export var speed: float = 200.0
@export var max_health: int = 100
@export_range(0, 1) var damage_reduction: float = 0.0
@export_group("Combat")
@export var attack_damage: int = 10
@export var attack_cooldown: float = 0.5
# Onready (initialized when ready)
@onready var sprite: Sprite2D = $Sprite2D
@onready var animation: AnimationPlayer = $AnimationPlayer
@onready var hitbox: Area2D = $Hitbox
# Private variables (convention: underscore prefix)
var _health: int
var _can_attack: bool = true
func _ready() -> void:
_health = max_health
func _physics_process(delta: float) -> void:
var direction := Input.get_vector("left", "right", "up", "down")
velocity = direction * speed
move_and_slide()
func take_damage(amount: int) -> void:
var actual_damage := int(amount * (1.0 - damage_reduction))
_health = max(_health - actual_damage, 0)
health_changed.emit(_health)
if _health <= 0:
died.emit()
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
常见问题
Godot 中的“信号”(signals)是什么?
信号就像对象在某件事发生时发出的通知(例如按钮被点击)。其他对象可以“监听”这些通知,并做出相应的反应。
什么是 GDScript?
GDScript 是 Godot 的主要编程语言,语法与 Python 相似,用来让你的游戏活起来。
Godot 中的“场景”(scenes)是什么?
场景就像游戏中可以反复使用的积木。你可以把它们看作角色、敌人或道具,方便地添加和修改。
详情
作者的原始描述
Master Godot 4 GDScript patterns including signals, scenes, state machines, and optimization. Use when building Godot games, implementing game systems, or learning GDScript best practices.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6703
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …