@ai-game-assets/phaser

中文文档
0.11.39发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 3007

Phaser integration and in-game designer for prompt-aware AI game assets.

原始使用文档

@ai-game-assets/phaser

Phaser loading, runtime helpers, and the in-game asset designer for AI Game Assets.

Play the Space Invaders demo · View this package on npm · Read the full documentation

npm install @ai-game-assets/core @ai-game-assets/phaser phaser

Use this package to load manifest assets into Phaser, react to designer previews, and install the debug-only asset designer during development.

The designer's Image model selector offers GPT Image 2.5 Sunburst (the default) and GPT Image 2.5 Flare for raster generation, edits, sprites, and tileset animations. Assets with an explicit legacy or custom settings.model retain that choice. Promote a generated option to save its model preference; SVG and audio keep their own providers.

Unpromoted prompt and field edits survive switching assets, targets, and animations during the current session. Refreshing resets them to the saved definitions. Use Add reference to choose an asset or animation sheet, upload an image, or sketch with the built-in editor. That reference takes priority over existing visual references and remains selected during the session until removed.

Scaled variants

The asset designer's Scaled variants... button manages alternate resolutions of the current source version. Set width and height (per frame for animations/sheets, per tile for tilesets), then Generate. If that resolution already exists, the form switches to Regenerate and replaces that variant only after you save a candidate; you do not need to select Edit first. Edit changes the dimensions and offers Regenerate; Touch up… opens the existing pixel editor; Delete removes a variant from use. Promote saves the selected candidate while keeping the dialog open. After selecting a candidate, Close becomes Save and close and waits for the save and runtime update before closing; a failed save keeps the dialog and selection open for retry. Closing without a selection retains the candidates when you reopen this dialog in the same designer session. Discard candidates clears that pending batch. The source image, logical asset dimensions, frame order, and animation timing remain unchanged. A newly promoted source starts with its own variants.

The Scaled variants dialog generates three candidates before saving. Each animation candidate has Animate/Stop controls using the original frame order and timing. Select a candidate and Promote to save it, or discard the candidates. Regeneration keeps the existing variant until its replacement is promoted. Saved animations can also be previewed with Animate.

Generation selects the closest available resolution by scale ratio, preferring the larger source on a tie. Regeneration excludes the variant being replaced. Strict pixels uses exact nearest-neighbor RGBA copying. Smooth resize uses deterministic resampling. OpenAI image upscale uses the existing OpenAI key and a preservation prompt; it may refine details. Downscaling in that mode uses deterministic smooth resizing. The AI result’s transparency is retained and sheets are processed one cell at a time.

loadAiAsset/loadAiAssets load the active version's variants. AiAssetRuntime automatically selects available variants for bindTexture and playAnimation targets after each scene update, based on displayed size, main-camera zoom, canvas display scaling, and device pixel ratio. Frame, origin, flipping, and world-space display size are retained. Missing variant textures fall back to an available source; live variant saves load asynchronously; deletion falls back immediately. Active generation previews take priority over saved variants.

For custom cameras, render textures, or explicit synchronization, call runtime.applyScaledVariant(sprite, assetId, { width, height, frame }), where width/height are desired screen-pixel dimensions. Omit dimensions to use the main camera and canvas measurements. Set scaledVariants: false in runtime options to disable selection. Plain Phaser sprites not managed by the runtime can use the exported applyAiScaledVariant helper. Animated tileset sequence textures remain separate from variants of the base sheet.

版本与发布记录

@ai-game-assets/phaser 共发布 61 个版本,首次发布于 2026/06/17;过去 12 个月发布了 61 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.11.39latest2026/11/08今天
0.11.382026/11/08今天
0.11.372026/11/034 天前
0.11.362026/11/016 天前
0.11.352026/11/016 天前
0.11.342026/11/016 天前

关于 @ai-game-assets/phaser 的常见问题

@ai-game-assets/phaser 是什么?

Phaser integration and in-game designer for prompt-aware AI game assets.

如何安装 @ai-game-assets/phaser?

在项目目录运行 npm install @ai-game-assets/phaser,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:phaser(>=4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ai-game-assets/phaser 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ai-game-assets/phaser 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ai-game-assets/phaser 可以商用吗?

@ai-game-assets/phaser 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ai-game-assets/phaser 的下载量有多少?

根据 npm 官方下载统计,@ai-game-assets/phaser 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,007 次,日均约 100 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ai-game-assets/phaser 还在维护吗?

最新版本 0.11.39 发布于 2026/11/08(今天);至今共发布 61 个版本,其中过去 12 个月发布了 61 个;首次发布于 2026/06/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。