游戏定义到自动生图工作流.md 15 KB

游戏定义到自动生图工作流

目标:把“一个游戏想法 + 参考图”稳定转换成 animation_manifest.json,再自动生成素材、预览资源库、导出 Cocos 整合包。

当前系统已经完成后半段:

animation_manifest.json
  -> 角色 / UI 美术 / 粒子 / Tween 自动生成
  -> 网页资源库预览
  -> Cocos 整合包

还缺的前半段是“游戏定义层”:

规范需求 + 参考图
  -> 文字模型生成游戏细则
  -> 文字模型生成 manifest
  -> 自动生图 / 导出

1. 总流程

01 输入需求包
   game_request.md + reference_images/

02 文字模型做策划细化
   输出 game_design_spec.json

03 文字模型做游戏反馈定义
   输出 feedback_spec.json

04 文字模型做资源拆解
   输出 asset_plan.json

05 文字模型生成 animation_manifest.json
   必须通过 schema 校验

06 Anim Studio 生成素材
   characters / ui_art / vfx / ui

07 网页 QA
   预览、删错、补生、重生

08 导出 Cocos 包
   out/<game>/cocos-pack/

这个流程里,文字模型不直接生图,只负责把需求变成稳定、完整、可复用的 manifest。图像模型只按 manifest 执行。

如果游戏品类是 slot / 老虎เกมสล็อต,建议在 game_design_spec.json 后增加一层 slot_game_config.json,让用户通过表单点选转轮模式、特殊符号、bonus、反馈强度和资产范围。完整模板见:老虎机玩法配置工作流.mdslot_game_config_template.json

2. 输入格式:game_request.md

每个新游戏先填一份规范需求,避免只靠一句话让模型乱发挥。

# 游戏需求

## 基本信息
- 游戏代号:jelly-candy-slot
- 品类:竖屏 H5 slot
- 引擎:Cocos Creator 3.8.x
- 目标画幅:竖屏,参考 798x1724
- 核心体验:轻松、甜品、果冻弹性、中奖反馈强

## 玩法
- 转轮:5 列 x 3 行
- 操作:Spin、下注加减、自动旋转
- 奖励:普通中奖、Big Win、Free Spin
- 核心循环:下注 -> Spin -> 停轮 -> 结算 -> 中奖反馈

## 美术方向
- 主题:果冻糖果世界
- 材质:3D 渲染感、半透明果冻、厚高光
- 色彩:高饱和糖果色,背景明亮,UI 蓝紫为主
- 禁止:写实人物、灰暗、恐怖、复杂文字

## 必要素材
- 吉祥物 / 符号:8 个果冻角色 + 金币 + lucky seven
- UI 美术:主背景、logo、转轮框、spin 按钮、圆形小按钮、HUD 面板
- 特效:金币雨、中奖爆光、大赢光晕、彩纸
- 动效:按钮按压、弹窗入场、面板滑入、数字滚动、图标呼吸

## 参考图
- reference_images/ref_01.png:整体色彩与糖果世界
- reference_images/ref_02.png:按钮质感
- reference_images/ref_03.png:转轮布局

## 约束
- 所有资产必须原创,不能复刻参考图里的具体角色或 logo。
- 角色图尽量居中、完整、干净边缘。
- 透明素材不要画棋盘格背景。

3. 中间产物一:game_design_spec.json

文字模型第一步输出“游戏定义”,用于统一后续判断。

{
  "game": "jelly-candy-slot",
  "genre": "vertical_h5_slot",
  "engine": "cocos_creator_3_8",
  "viewport": { "orientation": "portrait", "width": 798, "height": 1724 },
  "core_loop": ["bet", "spin", "reel_stop", "payout", "win_feedback"],
  "screen_tree": {
    "main": ["background", "logo", "reel_area", "mascot_or_symbols", "hud", "spin_button"],
    "overlays": ["win_popup", "free_spin_popup", "settings", "paytable"]
  },
  "art_direction": {
    "theme": "jelly candy land",
    "materials": ["translucent jelly", "glossy candy", "soft highlights"],
    "palette": ["pink", "blue", "purple", "gold", "lemon yellow"],
    "negative": ["photorealistic human", "dark horror", "busy text", "checkerboard background"]
  }
}

4. 游戏反馈定义:feedback_spec.json

这一步专门约束“玩家操作后游戏如何回应”。它不直接生图,但会决定需要哪些动效、粒子、角色动画、弹窗素材和声音占位。

没有这一层,模型通常只会生成静态素材,Cocos 包也只像“素材展厅”,不像一个有手感的游戏。

{
  "feedback_principles": {
    "overall_feel": "juicy, elastic, bright, fast response",
    "timing": "tap feedback within 80ms, win reveal within 600ms after reels stop",
    "intensity_levels": ["micro", "normal_win", "big_win", "bonus"],
    "avoid": ["long blocking animations", "dark flashes", "unclear win state"]
  },
  "player_actions": [
    {
      "id": "tap_spin",
      "trigger": "player_taps_spin_button",
      "visual": ["spin button compresses", "button glow pulses once"],
      "ui_animation": ["spin_btn_press"],
      "vfx": [],
      "sound_cue": "soft_pop",
      "duration_ms": 180
    },
    {
      "id": "change_bet",
      "trigger": "player_taps_bet_plus_or_minus",
      "visual": ["bet value bumps", "small pill highlight"],
      "ui_animation": ["balance_roll", "pulse"],
      "vfx": [],
      "sound_cue": "tick",
      "duration_ms": 220
    }
  ],
  "game_events": [
    {
      "id": "reels_start",
      "trigger": "spin_started",
      "visual": ["reel frame glow dims", "symbols blur vertically"],
      "ui_animation": ["panel_slide_in"],
      "vfx": [],
      "duration_ms": 300
    },
    {
      "id": "small_win",
      "trigger": "payout_greater_than_bet",
      "visual": ["winning symbols bounce", "win amount rolls up"],
      "characters": [{ "role": "winning_symbols", "animation": "win" }],
      "ui_animation": ["scale_bounce", "number_roll"],
      "vfx": ["win_burst"],
      "sound_cue": "win_small",
      "duration_ms": 900
    },
    {
      "id": "big_win",
      "trigger": "payout_at_least_10x_bet",
      "visual": ["big win popup enters", "mascot plays win", "coins rain over screen"],
      "characters": [{ "role": "mascot_or_symbols", "animation": "win" }],
      "ui_animation": ["reward_popup_in", "win_icon_pulse", "number_roll"],
      "vfx": ["coin_rain", "bigwin_glow", "confetti_pop"],
      "sound_cue": "win_big",
      "duration_ms": 2400,
      "blocks_input": true
    },
    {
      "id": "bonus_enter",
      "trigger": "free_spin_unlocked",
      "visual": ["screen bright flash", "free spin badge pops in", "background glow increases"],
      "ui_animation": ["elastic_in", "pulse"],
      "vfx": ["confetti_pop", "bigwin_glow"],
      "sound_cue": "bonus_unlock",
      "duration_ms": 1800,
      "blocks_input": true
    }
  ],
  "state_feedback": [
    {
      "id": "insufficient_balance",
      "trigger": "spin_blocked_by_low_balance",
      "visual": ["balance pill shakes", "spin button disabled tint"],
      "ui_animation": ["scale_bounce"],
      "vfx": [],
      "sound_cue": "error_soft",
      "duration_ms": 320
    },
    {
      "id": "auto_spin_active",
      "trigger": "auto_spin_enabled",
      "visual": ["auto button glows", "spin button shows loop state"],
      "ui_animation": ["pulse"],
      "vfx": [],
      "duration_ms": -1
    }
  ]
}

每个反馈事件建议统一使用这些字段:

字段 用途
id 反馈事件唯一 id
trigger 由玩法逻辑触发的条件
priority 多个反馈同时出现时谁优先
intensity micro / normal_win / big_win / bonus
visual 人能读懂的视觉描述
characters 哪些角色或符号播放哪段 Spine 动画
ui_animation 使用哪些 tween preset 或 ui 动效 id
vfx 使用哪些粒子特效 id
sound_cue 声音占位名,后续可接音频管线
haptics 震动占位名,H5 可忽略,App 可用
duration_ms 总时长,-1 表示持续状态
can_overlap 是否允许和其他反馈叠加
blocks_input 播放期间是否阻塞点击

反馈强度建议固定为四档:

强度 用途 时长 典型表现
micro 点击、切换、普通状态变化 80-300ms 按钮压缩、数值轻弹、小音效
normal_win 小奖、普通命中 600-1200ms 符号 bounce、金额滚动、小爆光
big_win 大奖、高倍赔付 1800-3500ms 弹窗、金币雨、角色 win、强音效
bonus 免费旋转、特殊模式 1500-3000ms 转场、徽章、彩纸、背景变亮

feedback_spec.json 会反向约束 manifest:

  • 如果反馈里用了 coin_rain,manifest 的 vfx 必须有 coin_rain
  • 如果反馈里用了 reward_popup_in,manifest 的 ui 必须有对应动效。
  • 如果反馈里用了角色 win,对应 characters[].animations 必须包含 win
  • 如果反馈里出现 big_win_popup 这类 UI 表现,ui_art 应该补对应弹窗或徽章素材。

5. 中间产物二:asset_plan.json

第二步把游戏定义拆成资产清单。它不是最终 manifest,而是给人检查的“策划表”。

{
  "characters": [
    { "id": "jelly_blue", "role": "low_symbol", "description": "blue blueberry jelly mascot", "animations": ["idle", "win"] },
    { "id": "symbol_seven", "role": "high_symbol", "description": "lucky seven symbol", "animations": ["idle", "win"] }
  ],
  "ui_art": [
    { "id": "bg_main", "role": "main_scene_background", "transparent": false, "size": "1024x1536" },
    { "id": "btn_spin", "role": "primary_action_button", "transparent": true, "size": "1024x1024" }
  ],
  "vfx": [
    { "id": "coin_rain", "template": "rain", "trigger": "big_win" }
  ],
  "ui": [
    { "id": "spin_btn_press", "preset": "scale_bounce", "target": "spin_button" }
  ]
}

6. 最终产物:animation_manifest.json

第三步才生成当前系统能直接执行的 manifest。

原则:

  • game 必须短横线命名,作为输出目录名。
  • style 是全局风格,不要塞具体角色。
  • characters[].prompt 只描述单个角色或符号。
  • ui_art[].prompt 只描述单个 UI 素材。
  • vfx 优先用已有模板:rainburstglowconfetti
  • ui 优先用已有预设:scale_bounceelastic_infade_slide_innumber_rollpulse
  • 禁止把玩法规则、长篇说明、多个素材混在一个 prompt 里。

7. 文字模型 Prompt 模板

7.1 生成游戏细则

你是 Cocos 3.8 竖屏 H5 游戏策划和技术美术。
请根据用户的 game_request.md 和参考图说明,输出 game_design_spec.json。

要求:
1. 只输出 JSON,不要 Markdown。
2. 资产必须原创,只学习参考图的品类、布局、材质和色彩,不复制具体角色、logo、文字。
3. 明确 genre、viewport、core_loop、screen_tree、art_direction、negative。
4. 不要生成 animation_manifest。

7.2 生成游戏反馈

你是 mobile game feel designer,擅长 slot / casual game 的反馈设计。
请根据 game_design_spec.json 输出 feedback_spec.json。

要求:
1. 只输出 JSON。
2. 必须包含 feedback_principles、player_actions、game_events、state_feedback。
3. 至少定义 tap_spin、reels_start、small_win、big_win、bonus_enter、insufficient_balance。
4. 每个反馈项必须包含 id、trigger、visual、duration_ms。
5. 优先复用已有动画预设:scale_bounce、elastic_in、fade_slide_in、number_roll、pulse。
6. 优先复用当前可生成的 vfx:coin_rain、win_burst、bigwin_glow、confetti_pop。
7. 不要创造无法落地的复杂镜头语言,保持 Cocos 2D 可实现。

7.3 生成资产拆解

你是游戏资产制片。
请根据 game_design_spec.json 和 feedback_spec.json 输出 asset_plan.json。

要求:
1. 只输出 JSON。
2. characters 控制在 8-12 个,包含普通符号、高价值符号或吉祥物。
3. ui_art 包含主背景、logo、转轮框、主按钮、次级按钮、HUD 面板。
4. vfx 只能使用 rain / burst / glow / confetti / trail 这些模板。
5. ui 只能使用已有 tween preset。
6. 每个 id 必须小写 snake_case 或 kebab-case,不能重复。
7. feedback_spec 里引用到的角色动画、vfx、ui preset,必须都能在 asset_plan 里找到对应资产。

7.4 生成 manifest

你是 Anim Studio manifest 生成器。
请根据 game_design_spec.json、feedback_spec.json 和 asset_plan.json 输出 animation_manifest.json。

要求:
1. 只输出 JSON。
2. 字段只能包含:game, style, characters, ui_art, vfx, ui。
3. characters 每项必须有 id,type,animations,prompt;type 固定 spine。
4. ui_art 每项必须有 id,transparent,size,prompt。
5. vfx 每项必须有 id,type,template,color;type 固定 particle。
6. ui 每项必须有 id,type,preset;type 固定 tween。
7. prompt 必须适合图像模型直接生图,清晰、短句、单素材、无版权角色。
8. feedback_spec 里使用的动画和特效必须在 manifest 中有对应定义。

8. 校验规则

生成 manifest 后必须自动检查:

  • JSON 能解析。
  • game 非空。
  • charactersui_artvfxui 至少一类非空。
  • 所有 id 在同类里唯一。
  • characters[].animations 只能包含当前支持动画,如 idlewin
  • ui_art[].size / 顶层 size 必须是当前模型支持尺寸。
  • vfx[].template 必须在粒子模板库内。
  • ui[].preset 必须在 tween 预设库内。
  • prompt 不得为空,不得包含“参考图同款”“复制 logo”“照抄”等风险词。
  • feedback_spec 引用的 vfx 必须存在于 manifest。
  • feedback_spec 引用的 ui_animation 必须存在于 manifest 的 ui[].presetui[].id
  • feedback_spec 引用的角色动画必须存在于对应 characters[].animations

校验失败时不要生图,先让文字模型修 manifest。

9. 网页功能建议

建议把当前网页顶部的“生成面板”升级成四步向导:

Step 1 游戏需求
  文本需求输入 + 参考图上传 + 目标品类选择

Step 2 AI 生成策划细则
  输出 game_design_spec.json 和 feedback_spec.json,可编辑

Step 3 AI 生成 manifest
  输出 animation_manifest.json,校验通过后才允许生成

Step 4 生成 / QA / 导出
  沿用当前生成面板、资源库预览、Cocos 导出

第一版不需要真的理解图片内容,可以先让用户给每张参考图写一句说明。后续再接视觉模型读取参考图。

10. 最小落地版本

优先做这 4 个文件/能力:

  1. game_request_template.md:需求输入模板。
  2. manifest_schema.py:校验 manifest + feedback 引用。
  3. design_prompts.py:四段文字模型 prompt。
  4. /api/design-to-manifest:输入需求文本,返回 game_design_spec / feedback_spec / asset_plan / manifest。

这样当前链路会变成:

填需求
  -> 生成反馈定义
  -> 生成 manifest
  -> 点开始生成
  -> 预览
  -> 导出 Cocos

这比一开始就做完整游戏逻辑更稳,因为先把“资源定义”标准化,后面再扩展玩法代码生成。

11. 和“定义游戏”的边界

这套流程能定义的是:

  • 品类与核心循环
  • 主场景 UI 结构
  • 美术风格
  • 游戏反馈层级与触发事件
  • 角色 / UI / 特效 / 动效资产清单
  • Cocos 资源包结构
  • 可运行演示场景

还不能完全自动定义的是:

  • 真实 slot 数学模型 / RTP / 赔付表
  • 商业化、登录、钱包、合规
  • 完整关卡系统或服务器协议
  • 复杂 Spine 多部件骨骼

所以阶段目标应定为:先自动生成“可看、可导入、可继续开发”的游戏原型资源包,而不是一次生成完整上线游戏。