A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
docs: fix API errors found during full documentation review
esenginef53e97926441
diff --git a/docs/astro/src/content/docs/core-concepts/components.mdx b/docs/astro/src/content/docs/core-concepts/components.mdxindex a8f9fd806..80f0d5a14 100644--- a/docs/astro/src/content/docs/core-concepts/components.mdx+++ b/docs/astro/src/content/docs/core-concepts/components.mdx@@ -106,6 +106,9 @@ UI text rendering. Works with `UIRect` and `Sprite` to display text. See [UI & T| `color` | Color | Text color RGBA || `align` | TextAlign | Horizontal alignment || `verticalAlign` | TextVerticalAlign | Vertical alignment |+| `wordWrap` | boolean | Enable word wrapping |+| `overflow` | TextOverflow | Overflow behavior: `Visible` (0), `Clip` (1), `Ellipsis` (2) |+| `lineHeight` | number | Line height multiplier |### UIRectdiff --git a/docs/astro/src/content/docs/core-concepts/resources.mdx b/docs/astro/src/content/docs/core-concepts/resources.mdxindex 231037c08..18baad3ee 100644--- a/docs/astro/src/content/docs/core-concepts/resources.mdx+++ b/docs/astro/src/content/docs/core-concepts/resources.mdx@@ -23,11 +23,11 @@ defineSystem([Res(Time)], (time) => {import { defineSystem, ResMut } from 'esengine';defineSystem([ResMut(GameState)], (state) => {- state.value.score += 10;+ state.get().score += 10;});```-`ResMut` wraps the resource value. Access the data with `.value`, or use `.modify()`:+`ResMut` wraps the resource value. Access the data with `.get()`, or use `.modify()`:```typescriptdefineSystem([ResMut(GameState)], (state) => {@@ -84,6 +84,9 @@ defineSystem([Res(Input)], (input) => {| `isKeyReleased(code)` | Key was released this frame || `getMousePosition()` | Returns `{ x, y }` || `isMouseButtonDown(button)` | Mouse button held (0=left, 2=right) |+| `isMouseButtonPressed(button)` | Mouse button was pressed this frame |+| `isMouseButtonReleased(button)` | Mouse button was released this frame |+| `getScrollDelta()` | Returns `{ x, y }` scroll delta |## Custom Resources@@ -121,7 +124,7 @@ defineSystem([Res(GameState)], (state) => {// MutabledefineSystem([ResMut(GameState)], (state) => {- state.value.score += 10;+ state.get().score += 10;});```@@ -153,7 +156,7 @@ addSystem(defineSystem(const dy = pPos.position.y - cPos.position.y;if (Math.sqrt(dx * dx + dy * dy) < 30) {cmds.despawn(coinEntity);- score.value.value += 1;+ score.get().value += 1;}}}diff --git a/docs/astro/src/content/docs/core-concepts/systems.mdx b/docs/astro/src/content/docs/core-concepts/systems.mdxindex cdbc5c017..25a054913 100644--- a/docs/astro/src/content/docs/core-concepts/systems.mdx+++ b/docs/astro/src/content/docs/core-concepts/systems.mdx@@ -99,8 +99,8 @@ defineSystem([Commands()], (cmds) => {|--------|---------|-------------|| `cmds.spawn()` | `EntityCommands` | Create a new entity, returns a builder || `cmds.entity(entity)` | `EntityCommands` | Get a builder for an existing entity |-| `cmds.despawn(entity)` | `Commands` | Queue entity for destruction |-| `cmds.insertResource(res, value)` | `Commands` | Insert or overwrite a resource |+| `cmds.despawn(entity)` | `this` | Queue entity for destruction |+| `cmds.insertResource(res, value)` | `this` | Insert or overwrite a resource |#### EntityCommands API@@ -113,7 +113,7 @@ defineSystem([Commands()], (cmds) => {| `.id()` | `Entity` | Get the entity ID |<Aside type="note">- Commands are buffered and applied at the end of the current schedule stage, not immediately. The exception is `.id()` — calling it triggers immediate entity creation so the ID is available right away.+ Commands are buffered and flushed after the system function returns, not applied inline during execution. The exception is `.id()` — calling it triggers immediate entity creation so the ID is available right away.</Aside>### Query@@ -148,7 +148,7 @@ defineSystem([Res(Time)], (time) => {import { ResMut } from 'esengine';defineSystem([ResMut(GameState)], (state) => {- state.value.score += 10;+ state.get().score += 10;});```diff --git a/docs/astro/src/content/docs/guides/bitmap-text.mdx b/docs/astro/src/content/docs/guides/bitmap-text.mdxindex 771079937..e92fbb1a1 100644--- a/docs/astro/src/content/docs/guides/bitmap-text.mdx+++ b/docs/astro/src/content/docs/guides/bitmap-text.mdx@@ -138,8 +138,8 @@ addSystem(defineSystem(BitmapText follows the same draw ordering as Sprite:-1. **Z position** (`transform.position.z`) — lower Z draws first (behind)-2. **Layer** (`bitmapText.layer`) — higher layer draws on top+1. **Layer** (`bitmapText.layer`) — primary sort key, higher layer draws on top+2. **Z position** (`transform.position.z`) — within the same layer, lower Z draws first (behind)## Next Stepsdiff --git a/docs/astro/src/content/docs/guides/render-texture.mdx b/docs/astro/src/content/docs/guides/render-texture.mdxindex 7effd7273..caa533275 100644--- a/docs/astro/src/content/docs/guides/render-texture.mdx+++ b/docs/astro/src/content/docs/guides/render-texture.mdx@@ -26,7 +26,7 @@ const rt: RenderTextureHandle = RenderTexture.create({|-------|------|---------|-------------|| `width` | `number` | — | Texture width in pixels || `height` | `number` | — | Texture height in pixels |-| `depth` | `boolean` | `false` | Attach a depth buffer |+| `depth` | `boolean` | `true` | Attach a depth buffer || `filter` | `'nearest' \| 'linear'` | `'nearest'` | Texture filtering mode |## Rendering to Texture@@ -34,11 +34,12 @@ const rt: RenderTextureHandle = RenderTexture.create({Wrap your draw calls between `begin()` and `end()`. Everything rendered in between goes to the texture instead of the screen:```typescript-import { RenderTexture, Draw } from 'esengine';+import { RenderTexture, Renderer } from 'esengine';RenderTexture.begin(rt, viewProjectionMatrix);-Draw.rect({ x: 0, y: 0 }, { x: 100, y: 100 }, { r: 1, g: 0, b: 0, a: 1 });+Renderer.submitSprites(registry);+Renderer.flush();RenderTexture.end();```diff --git a/docs/astro/src/content/docs/guides/rendering.mdx b/docs/astro/src/content/docs/guides/rendering.mdxindex 3551b6c16..0dfea558b 100644--- a/docs/astro/src/content/docs/guides/rendering.mdx+++ b/docs/astro/src/content/docs/guides/rendering.mdx@@ -170,13 +170,12 @@ The rendering pipeline is divided into stages that execute in order. Each stage| `Transparent` | 2 | Transparent/alpha-blended objects || `Overlay` | 3 | UI and overlay elements (drawn on top) |-When using [Custom Draw](/microes/guides/custom-draw/), specify a `RenderStage` to control when your draw commands execute relative to the built-in rendering:+Custom draw callbacks execute after the built-in sprite, text, and spine rendering within each camera pass. Use `Renderer.setStage()` in the render pipeline to control which stage is active:```typescript-import { Draw, RenderStage } from 'esengine';+import { Renderer, RenderStage } from 'esengine';-Draw.bindStage(RenderStage.Overlay);-Draw.rect(0, 0, 100, 50, { r: 0, g: 0, b: 0, a: 0.5 });+Renderer.setStage(RenderStage.Overlay);```## Next Stepsdiff --git a/docs/astro/src/content/docs/zh/core-concepts/components.mdx b/docs/astro/src/content/docs/zh/core-concepts/components.mdxindex 67e2ba191..7a69c8827 100644--- a/docs/astro/src/content/docs/zh/core-concepts/components.mdx+++ b/docs/astro/src/content/docs/zh/core-concepts/components.mdx@@ -106,6 +106,9 @@ UI 文本渲染。配合 `UIRect` 和 `Sprite` 组件显示文本。详见 [UI| `color` | Color | 文本颜色 RGBA || `align` | TextAlign | 水平对齐方式 || `verticalAlign` | TextVerticalAlign | 垂直对齐方式 |+| `wordWrap` | boolean | 是否启用自动换行 |+| `overflow` | TextOverflow | 溢出行为:`Visible` (0)、`Clip` (1)、`Ellipsis` (2) |+| `lineHeight` | number | 行高倍率 |### UIRectdiff --git a/docs/astro/src/content/docs/zh/core-concepts/resources.mdx b/docs/astro/src/content/docs/zh/core-concepts/resources.mdxindex 2997a9ffb..90c428a46 100644--- a/docs/astro/src/content/docs/zh/core-concepts/resources.mdx+++ b/docs/astro/src/content/docs/zh/core-concepts/resources.mdx@@ -23,11 +23,11 @@ defineSystem([Res(Time)], (time) => {import { defineSystem, ResMut } from 'esengine';defineSystem([ResMut(GameState)], (state) => {- state.value.score += 10;+ state.get().score += 10;});```-`ResMut` 包装了资源值。用 `.value` 访问数据,或使用 `.modify()`:+`ResMut` 包装了资源值。用 `.get()` 访问数据,或使用 `.modify()`:```typescriptdefineSystem([ResMut(GameState)], (state) => {@@ -84,6 +84,9 @@ defineSystem([Res(Input)], (input) => {| `isKeyReleased(code)` | 按键在这帧被释放 || `getMousePosition()` | 返回 `{ x, y }` || `isMouseButtonDown(button)` | 鼠标按钮被按住(0=左键,2=右键) |+| `isMouseButtonPressed(button)` | 鼠标按钮在这帧被按下 |+| `isMouseButtonReleased(button)` | 鼠标按钮在这帧被释放 |+| `getScrollDelta()` | 返回 `{ x, y }` 滚轮增量 |## 自定义资源@@ -121,7 +124,7 @@ defineSystem([Res(GameState)], (state) => {// 可变defineSystem([ResMut(GameState)], (state) => {- state.value.score += 10;+ state.get().score += 10;});```@@ -153,7 +156,7 @@ addSystem(defineSystem(const dy = pPos.position.y - cPos.position.y;if (Math.sqrt(dx * dx + dy * dy) < 30) {cmds.despawn(coinEntity);- score.value.value += 1;+ score.get().value += 1;}}}diff --git a/docs/astro/src/content/docs/zh/core-concepts/systems.mdx b/docs/astro/src/content/docs/zh/core-concepts/systems.mdxindex 45309f8cd..1fc5570ce 100644--- a/docs/astro/src/content/docs/zh/core-concepts/systems.mdx+++ b/docs/astro/src/content/docs/zh/core-concepts/systems.mdx@@ -99,8 +99,8 @@ defineSystem([Commands()], (cmds) => {|------|--------|------|| `cmds.spawn()` | `EntityCommands` | 创建新实体,返回构建器 || `cmds.entity(entity)` | `EntityCommands` | 获取已有实体的构建器 |-| `cmds.despawn(entity)` | `Commands` | 将实体加入销毁队列 |-| `cmds.insertResource(res, value)` | `Commands` | 插入或覆盖资源 |+| `cmds.despawn(entity)` | `this` | 将实体加入销毁队列 |+| `cmds.insertResource(res, value)` | `this` | 插入或覆盖资源 |#### EntityCommands API@@ -113,7 +113,7 @@ defineSystem([Commands()], (cmds) => {| `.id()` | `Entity` | 获取实体 ID |<Aside type="note">- Commands 是缓冲的,在当前调度阶段结束时才应用。例外是 `.id()` — 调用它会立即创建实体,使 ID 可以马上使用。+ Commands 是缓冲的,在系统函数返回后才统一应用,不会在执行过程中立即生效。例外是 `.id()` — 调用它会立即创建实体,使 ID 可以马上使用。</Aside>### Query@@ -148,7 +148,7 @@ defineSystem([Res(Time)], (time) => {import { ResMut } from 'esengine';defineSystem([ResMut(GameState)], (state) => {- state.value.score += 10;+ state.get().score += 10;});```diff --git a/docs/astro/src/content/docs/zh/guides/bitmap-text.mdx b/docs/astro/src/content/docs/zh/guides/bitmap-text.mdxindex d5f6c3754..2986547ed 100644--- a/docs/astro/src/content/docs/zh/guides/bitmap-text.mdx+++ b/docs/astro/src/content/docs/zh/guides/bitmap-text.mdx@@ -138,8 +138,8 @@ addSystem(defineSystem(BitmapText 遵循与 Sprite 相同的绘制排序规则:-1. **Z 坐标** (`transform.position.z`) — Z 值越小越先绘制(在后面)-2. **Layer** (`bitmapText.layer`) — layer 值越大越在上面+1. **Layer** (`bitmapText.layer`) — 主要排序依据,值越大越在上面+2. **Z 坐标** (`transform.position.z`) — 同 layer 内,Z 值越小越先绘制(在后面)## 下一步diff --git a/docs/astro/src/content/docs/zh/guides/render-texture.mdx b/docs/astro/src/content/docs/zh/guides/render-texture.mdxindex 50ca7351e..774ed73cc 100644--- a/docs/astro/src/content/docs/zh/guides/render-texture.mdx+++ b/docs/astro/src/content/docs/zh/guides/render-texture.mdx@@ -26,7 +26,7 @@ const rt: RenderTextureHandle = RenderTexture.create({|------|------|--------|------|| `width` | `number` | — | 纹理宽度(像素) || `height` | `number` | — | 纹理高度(像素) |-| `depth` | `boolean` | `false` | 是否附加深度缓冲 |+| `depth` | `boolean` | `true` | 是否附加深度缓冲 || `filter` | `'nearest' \| 'linear'` | `'nearest'` | 纹理过滤模式 |## 渲染到纹理@@ -34,11 +34,12 @@ const rt: RenderTextureHandle = RenderTexture.create({在 `begin()` 和 `end()` 之间进行绘制调用。期间渲染的所有内容都会输出到纹理而非屏幕:```typescript-import { RenderTexture, Draw } from 'esengine';+import { RenderTexture, Renderer } from 'esengine';RenderTexture.begin(rt, viewProjectionMatrix);-Draw.rect({ x: 0, y: 0 }, { x: 100, y: 100 }, { r: 1, g: 0, b: 0, a: 1 });+Renderer.submitSprites(registry);+Renderer.flush();RenderTexture.end();```diff --git a/docs/astro/src/content/docs/zh/guides/rendering.mdx b/docs/astro/src/content/docs/zh/guides/rendering.mdxindex 0f2e7187f..39ab7e991 100644--- a/docs/astro/src/content/docs/zh/guides/rendering.mdx+++ b/docs/astro/src/content/docs/zh/guides/rendering.mdx@@ -170,13 +170,12 @@ console.log(`Draw calls: ${stats.drawCalls}, Triangles: ${stats.triangles}`);| `Transparent` | 2 | 透明/Alpha 混合对象 || `Overlay` | 3 | UI 和覆盖元素(绘制在最上层) |-使用[自定义绘制](/microes/zh/guides/custom-draw/)时,指定 `RenderStage` 来控制绘制命令相对于内置渲染的执行时机:+自定义绘制回调在每个相机 pass 中的内置精灵、文本和 Spine 渲染之后执行。使用 `Renderer.setStage()` 在渲染管线中控制当前活跃的阶段:```typescript-import { Draw, RenderStage } from 'esengine';+import { Renderer, RenderStage } from 'esengine';-Draw.bindStage(RenderStage.Overlay);-Draw.rect(0, 0, 100, 50, { r: 0, g: 0, b: 0, a: 0.5 });+Renderer.setStage(RenderStage.Overlay);```## 下一步