Skip to content

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.

docs: sync guides with character-controller, tileset spacing, and scene-cancel fixes

esengine43b12dc6ee6a
diff --git a/docs/astro/src/content/docs/guides/physics.mdx b/docs/astro/src/content/docs/guides/physics.mdx
index 33e364a5d..54b5379a7 100644
--- a/docs/astro/src/content/docs/guides/physics.mdx
+++ b/docs/astro/src/content/docs/guides/physics.mdx
@@ -361,15 +361,20 @@ body automatically, so its `maskBits` need not avoid its own collision layer. Dr
| `velocity` | Vec2 | `{0, 0}` | Desired velocity in world pixels/second (set each step). |
| `up` | Vec2 | `{0, 1}` | Up direction for floor/ceiling classification. |
| `floorMaxAngle` | number | `0.785` | Max walkable slope from `up`, radians (45°). |
+| `skinWidth` | number | `1` | Gap kept off surfaces (pixels) so the body doesn't stick or jitter. |
+| `maxSlides` | number | `4` | Max depenetration slide iterations per move (clamped to ≥1). |
+| `snapLength` | number | `0` | Down-probe length (pixels) that glues the body to descending stairs/slopes; `0` disables it. Skipped while rising, so a jump still leaves the ground. |
+| `slideOnCeiling` | boolean | `true` | When `false`, a ceiling hit cancels the upward velocity instead of sliding along it. |
| `maskBits` | number | `0xFFFF` | Layers that block the character. |
| `isOnFloor` / `isOnWall` / `isOnCeiling` | boolean | — | **Output**: what was touched this move. |
| `floorNormal` | Vec2 | — | **Output**: normal of the last floor touched. |
| `realVelocity` | Vec2 | — | **Output**: actual displacement / dt after collisions. |
-<Aside type="note">`maxSlides`, `skinWidth`, `snapLength`, and `slideOnCeiling` remain on
-the component for the standalone `moveAndSlide` resolver (`esengine/physics`); the
-native mover the live controller uses does its own iteration and gap handling, so it
-ignores them. Stair/slope floor-snap (`snapLength`) is a planned mover addition.</Aside>
+<Aside type="note">`skinWidth`, `maxSlides`, `snapLength`, and `slideOnCeiling` are honored by
+the live native mover **and** by the standalone `moveAndSlide` resolver (`esengine/physics`),
+so they behave the same whichever path you use. The defaults suit a standard character; the
+common tweak is a small `snapLength` (a few pixels) to keep the character glued to descending
+stairs and slopes.</Aside>
## Debug draw
diff --git a/docs/astro/src/content/docs/guides/scene.mdx b/docs/astro/src/content/docs/guides/scene.mdx
index d2eb3704d..e59f23dc5 100644
--- a/docs/astro/src/content/docs/guides/scene.mdx
+++ b/docs/astro/src/content/docs/guides/scene.mdx
@@ -32,6 +32,12 @@ ramps back over the second half. The awaited promise resolves only after the
fade-in completes — and rejects if the load failed. A `switchTo` issued while a
transition is in flight is ignored with a warning; `isTransitioning()` tells you.
+If a load is superseded before it commits — an `unload`, or another load of the
+same scene, races ahead of it — the pending promise rejects with a
+`SceneLoadCancelled` error rather than committing a half-loaded scene. It is a
+race signal, not a real failure, so branch on it in your `catch` (e.g. ignore it)
+instead of surfacing it as a load error.
+
| Option | Type | Default | Description |
|---|---|---|---|
| `transition` | `'none' \| 'fade'` | `'none'` | Hard cut, or fade through `color`. |
diff --git a/docs/astro/src/content/docs/guides/tilemap.mdx b/docs/astro/src/content/docs/guides/tilemap.mdx
index f96cdd602..f52f2175b 100644
--- a/docs/astro/src/content/docs/guides/tilemap.mdx
+++ b/docs/astro/src/content/docs/guides/tilemap.mdx
@@ -159,10 +159,16 @@ One layer can draw from several tilesets. Give it a slot table — each slot map
```typescript
tilemap.setTilesets(layer, [
{ firstId: 1, textureHandle: grassTex, columns: 8 },
- { firstId: 256, textureHandle: propsTex, columns: 8 },
+ { firstId: 256, textureHandle: propsTex, columns: 8, margin: 4, spacing: 8 },
]);
```
+Optional `margin` (border before the first tile) and `spacing` (gap between tiles),
+both in pixels, describe atlases that pad their cells — each tile then samples its
+own texels instead of bleeding toward its neighbour. They default to `0`, so a
+gapless atlas needs neither; the Tiled/`.estileset` importer fills them in
+automatically from the tileset's own margin/spacing.
+
## Tile animation
Author animated tiles in the **Tileset editor**: open the `.estileset`, switch the
diff --git a/docs/astro/src/content/docs/zh-cn/guides/physics.mdx b/docs/astro/src/content/docs/zh-cn/guides/physics.mdx
index 6bbe2293f..f73d3c982 100644
--- a/docs/astro/src/content/docs/zh-cn/guides/physics.mdx
+++ b/docs/astro/src/content/docs/zh-cn/guides/physics.mdx
@@ -335,14 +335,18 @@ const drive = defineSystem([Query(Mut(CharacterController))], (q) => {
| `velocity` | Vec2 | `{0, 0}` | 期望速度(世界像素/秒,每步设置)。 |
| `up` | Vec2 | `{0, 1}` | 用于地面/天花板分类的上方向。 |
| `floorMaxAngle` | number | `0.785` | 相对 `up` 的最大可行走坡度,弧度(45°)。 |
+| `skinWidth` | number | `1` | 与表面保持的间隙(像素),避免贴壁抖动。 |
+| `maxSlides` | number | `4` | 每次移动的最大脱离滑动迭代次数(下限为 1)。 |
+| `snapLength` | number | `0` | 向下探测长度(像素),把角色吸附在下行的台阶/斜坡上;`0` 表示关闭。上升时跳过,所以跳跃仍能离地。 |
+| `slideOnCeiling` | boolean | `true` | 为 `false` 时,撞到天花板会取消向上速度,而不是沿其滑动。 |
| `maskBits` | number | `0xFFFF` | 阻挡角色的层。 |
| `isOnFloor` / `isOnWall` / `isOnCeiling` | boolean | — | **输出**:这次移动碰到了什么。 |
| `floorNormal` | Vec2 | — | **输出**:最后接触地面的法线。 |
| `realVelocity` | Vec2 | — | **输出**:碰撞后的实际位移 / dt。 |
-<Aside type="note">`maxSlides`、`skinWidth`、`snapLength`、`slideOnCeiling` 仍保留在组件上,
-供独立的 `moveAndSlide` 解析器(`esengine/physics`)使用;实际控制器用的原生 mover 自带迭代与
-间隙处理,会忽略它们。斜坡/台阶的地面吸附(`snapLength`)是 mover 计划中的补充。</Aside>
+<Aside type="note">`skinWidth`、`maxSlides`、`snapLength`、`slideOnCeiling` 由运行时原生 mover
+**以及**独立的 `moveAndSlide` 解析器(`esengine/physics`)共同遵循,两条路径行为一致。默认值适合
+普通角色;最常见的微调是给 `snapLength` 一个较小值(几个像素),让角色贴住下行的台阶和斜坡。</Aside>
## 调试绘制
diff --git a/docs/astro/src/content/docs/zh-cn/guides/scene.mdx b/docs/astro/src/content/docs/zh-cn/guides/scene.mdx
index d2e259931..516179816 100644
--- a/docs/astro/src/content/docs/zh-cn/guides/scene.mdx
+++ b/docs/astro/src/content/docs/zh-cn/guides/scene.mdx
@@ -28,6 +28,10 @@ const goToLevel2 = defineSystem([Res(SceneManager)], async (scenes) => {
promise 只在淡入完成后 resolve——加载失败则 reject。过渡进行中再调 `switchTo` 会被忽略并
打警告;`isTransitioning()` 可以查询。
+如果一次加载在提交前被抢占——`unload`,或对同一场景的另一次加载抢先完成——待定的 promise
+会以 `SceneLoadCancelled` 错误 reject,而不会提交一个只加载了一半的场景。它是竞态信号,不是
+真正的失败,所以请在 `catch` 里对它单独分支处理(例如直接忽略),而不要当成加载错误上报。
+
| 选项 | 类型 | 默认 | 说明 |
|---|---|---|---|
| `transition` | `'none' \| 'fade'` | `'none'` | 硬切,或经 `color` 淡入淡出。 |
diff --git a/docs/astro/src/content/docs/zh-cn/guides/tilemap.mdx b/docs/astro/src/content/docs/zh-cn/guides/tilemap.mdx
index 1515becdc..fd5fbdd75 100644
--- a/docs/astro/src/content/docs/zh-cn/guides/tilemap.mdx
+++ b/docs/astro/src/content/docs/zh-cn/guides/tilemap.mdx
@@ -145,10 +145,14 @@ tilemap.worldToTile(layer, wx, wy, 0, 0); // → { x, y }
```typescript
tilemap.setTilesets(layer, [
{ firstId: 1, textureHandle: grassTex, columns: 8 },
- { firstId: 256, textureHandle: propsTex, columns: 8 },
+ { firstId: 256, textureHandle: propsTex, columns: 8, margin: 4, spacing: 8 },
]);
```
+可选的 `margin`(第一个 tile 前的边距)和 `spacing`(tile 之间的间隙)以像素为单位,用于描述
+单元之间留白的图集——这样每个 tile 只采样自己的纹素,不会渗到相邻 tile。两者默认为 `0`,所以
+无间隙图集无需设置;Tiled / `.estileset` 导入器会自动从图集自身的 margin/spacing 填入。
+
## 瓦片动画
动画瓦片在**图集编辑器**里创作:打开 `.estileset`,把模式切到**动画**,点击要动画的