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: correct render order priority description

esengine33949e45eef6
diff --git a/docs/astro/src/content/docs/guides/rendering.mdx b/docs/astro/src/content/docs/guides/rendering.mdx
index 81ed3e917..2c9e55198 100644
--- a/docs/astro/src/content/docs/guides/rendering.mdx
+++ b/docs/astro/src/content/docs/guides/rendering.mdx
@@ -122,13 +122,18 @@ transform.scale = { x: -1, y: 1, z: 1 }; // Flip horizontally
## Render Order
-Sprites are drawn in order by:
+Sprites are sorted by the following priority (highest first):
-1. **Z position** (`transform.position.z`) — lower Z draws first (behind)
-2. **Layer** (`sprite.layer`) — higher layer draws on top
+1. **Layer** (`sprite.layer`) — primary sort key, higher layer draws on top
+2. **Texture** — within the same layer, sprites are batched by texture to reduce draw calls
+3. **Z position** (`transform.position.z`) — within the same layer and texture, lower Z draws first (behind)
Set these values in the inspector when placing entities, or modify them at runtime in systems.
+<Aside type="caution">
+ `position.z` only affects ordering among sprites with the same layer and texture. To reliably control draw order between sprites with different textures, use `sprite.layer`.
+</Aside>
+
<Aside type="tip">
The C++ backend handles all WebGL rendering. You just set component data and the engine draws everything automatically each frame.
</Aside>
diff --git a/docs/astro/src/content/docs/guides/sprite.mdx b/docs/astro/src/content/docs/guides/sprite.mdx
index 37185f641..8e98464f7 100644
--- a/docs/astro/src/content/docs/guides/sprite.mdx
+++ b/docs/astro/src/content/docs/guides/sprite.mdx
@@ -120,12 +120,15 @@ addSystem(defineSystem(
## Render Order
-Sprites are drawn by:
+Sprites are sorted by the following priority (highest first):
-1. **Z position** (`transform.position.z`) — lower Z draws first (behind)
-2. **Layer** (`sprite.layer`) — higher layer draws on top
+1. **Layer** (`sprite.layer`) — primary sort key, higher layer draws on top
+2. **Texture** — within the same layer, sprites are batched by texture to reduce draw calls
+3. **Z position** (`transform.position.z`) — within the same layer and texture, lower Z draws first (behind)
-Set these in the inspector or modify at runtime.
+<Aside type="caution">
+ `position.z` only affects ordering among sprites with the same layer and texture. To reliably control draw order between sprites with different textures, use `sprite.layer`.
+</Aside>
## Runtime Spawning
diff --git a/docs/astro/src/content/docs/zh/guides/rendering.mdx b/docs/astro/src/content/docs/zh/guides/rendering.mdx
index 9d4c64801..c976e251f 100644
--- a/docs/astro/src/content/docs/zh/guides/rendering.mdx
+++ b/docs/astro/src/content/docs/zh/guides/rendering.mdx
@@ -122,13 +122,18 @@ transform.scale = { x: -1, y: 1, z: 1 }; // 水平翻转
## 渲染顺序
-精灵按以下顺序绘制:
+精灵按以下优先级排序绘制(高优先级在前):
-1. **Z 坐标** (`transform.position.z`) — Z 值越小越先绘制(在后面)
-2. **Layer** (`sprite.layer`) — layer 值越大越在上面
+1. **Layer** (`sprite.layer`) — 主要排序依据,值越大越在上面
+2. **Texture** — 同 layer 内按纹理分组批处理,减少 draw call
+3. **Z 坐标** (`transform.position.z`) — 同 layer、同纹理内,Z 值越小越先绘制(在后面)
在检查器中设置或运行时修改。
+<Aside type="caution">
+ `position.z` 仅在同 layer、同纹理的精灵之间生效。如需可靠地控制不同纹理精灵的前后顺序,请使用 `sprite.layer`。
+</Aside>
+
<Aside type="tip">
C++ 后端负责所有 WebGL 渲染。你只需设置组件数据,引擎每帧自动绘制一切。
</Aside>
diff --git a/docs/astro/src/content/docs/zh/guides/sprite.mdx b/docs/astro/src/content/docs/zh/guides/sprite.mdx
index 35594ad7d..5733e148a 100644
--- a/docs/astro/src/content/docs/zh/guides/sprite.mdx
+++ b/docs/astro/src/content/docs/zh/guides/sprite.mdx
@@ -120,12 +120,15 @@ addSystem(defineSystem(
## 渲染顺序
-精灵按以下顺序绘制:
+精灵按以下优先级排序绘制(高优先级在前):
-1. **Z 坐标** (`transform.position.z`) — Z 值越小越先绘制(在后面)
-2. **Layer** (`sprite.layer`) — layer 值越大越在上面
+1. **Layer** (`sprite.layer`) — 主要排序依据,值越大越在上面
+2. **Texture** — 同 layer 内按纹理分组批处理,减少 draw call
+3. **Z 坐标** (`transform.position.z`) — 同 layer、同纹理内,Z 值越小越先绘制(在后面)
-在检查器中设置或运行时修改。
+<Aside type="caution">
+ `position.z` 仅在同 layer、同纹理的精灵之间生效。如需可靠地控制不同纹理精灵的前后顺序,请使用 `sprite.layer`。
+</Aside>
## 运行时创建