lili 85f48228cd
Some checks failed
contract-gates / contract-gates (push) Has been cancelled
docs-gate / docs-gate (push) Has been cancelled
feat(cheap-gen): W-AXIS 波3 知识层补强+收尾——tsc 顾问门+recipes+暗资产接线+n=5 基线台账
- tsc 顾问门:typescript devDependency + tsc-advisory 测试档;顾问性(永不阻断),
  金标 10 款零误伤抽验
- recipes/ 五篇高频场景索引(命中矩形/计时器/资产回退/场景机/结算演出,「抄这段形态
  +头号病根」)+ littlejs-game-dev §0.5 卡壳就查接线
- 暗资产接线:plugin-capability-map(11 注入+1 取证+6 储备逐件裁定)+
  engine-capabilities-brief(≤3KB 蒸馏)+ api.d.ts/game-host.d.ts 补插件指针;
  三方一致性对账门 plugin-surface-gate.py(含 cwd 锚定修)挂 pre-commit+Gitea Actions
- hard_genre_batch 参数化(五品类 n=5 批跑驱动,checkpoint 续跑)
- n=5 基线台账入库(gitignore 例外 add -f,只入台账不入游戏产物):
  wax-baseline.jsonl 25 局逐局记录(含判定仪器订正批注:cap1500 重判/图像盲 M3 重判,
  只加字段零改值)——终数:操作口径 14/25=56%、质量口径 18/25=72%;
  品类 narrative/heritage 5/5、trpg 4/5、puzzle/sim-business 2/5(缺口逐局有名有姓,
  根因见 07-10 v2 plan §1);旧「80%/39%」口径正式作废存照

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 04:27:18 -07:00

1.4 KiB
Raw Blame History

recipe: 资产回退(缺图/加载失败不崩)

要做:用 assets/ 里的美术图渲染角色/物品,缺图或加载失败时程序化画个占位、绝不崩。

病根九成在这g.drawImage(assets[ref].image, ...) 直接取用不判 null。缺图时 assets[ref].imagenulldrawImage(null) 当场抛 → 整局崩。headless 有图测不到,真人换环境缺图才爆。

根治每次取图都 ?.image + if (img) 画 else 程序化回退。ref = manifest 条目 file 去扩展名(shopkeeper-idle.jpg'shopkeeper-idle')。

抄这段形态

async init(boot) {
  this.ctx = boot.ctx;
  this.assets = boot.assets || {};   // host 已预载;无美术游戏时是 {}
}

render(g) {
  const img = this.assets['shopkeeper-idle']?.image;   // ★?. 兜 null
  if (img) {
    g.drawImage(img, x, y, w, h);
  } else {
    // 程序化回退:画个色块占位,绝不因缺图崩
    g.fillStyle = '#c8a06a';
    g.fillRect(x, y, w, h);
  }
}

别踩

  • read_file('assets/manifest.json') 看有哪些资产(非空才有图);无 manifest / 无美术 → 全程序化绘制即可,别硬编码文件名。
  • BGM/音效不在 boot.assets——走 plugins.audioMusicplaySfx('coin') / play(intensity))。
  • 改一张图:mmx 重生成覆盖同名文件 + 更新 manifest 的 sha256/bytes/prompt文件名没变 → 代码一行不用动