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.

fix: correct particle guide code examples to match SDK API

esenginede91dcecfbe7
diff --git a/docs/astro/src/content/docs/guides/particles.mdx b/docs/astro/src/content/docs/guides/particles.mdx
index 8c3d8055a..c90036d08 100644
--- a/docs/astro/src/content/docs/guides/particles.mdx
+++ b/docs/astro/src/content/docs/guides/particles.mdx
@@ -215,16 +215,16 @@ emitter.colorEasing = ParticleEasing.EaseInOut;
```typescript
import {
- defineSystem, addSystem, Commands, Transform,
+ defineSystem, addStartupSystem, Commands, Transform,
ParticleEmitter, EmitterShape, ParticleEasing
} from 'esengine';
-addSystem(defineSystem(
- [Commands],
+addStartupSystem(defineSystem(
+ [Commands()],
(commands) => {
- commands.spawn(
- Transform.bundle({ position: { x: 400, y: 300, z: 0 } }),
- ParticleEmitter.bundle({
+ commands.spawn()
+ .insert(Transform, { position: { x: 400, y: 300, z: 0 } })
+ .insert(ParticleEmitter, {
rate: 30,
lifetimeMin: 0.5,
lifetimeMax: 1.5,
@@ -244,10 +244,8 @@ addSystem(defineSystem(
colorEasing: ParticleEasing.EaseOut,
gravity: { x: 0, y: -50 },
blendMode: 1,
- }),
- );
- },
- { runCondition: 'once' }
+ });
+ }
));
```
diff --git a/docs/astro/src/content/docs/zh/guides/particles.mdx b/docs/astro/src/content/docs/zh/guides/particles.mdx
index eae811bce..8bd1adc3f 100644
--- a/docs/astro/src/content/docs/zh/guides/particles.mdx
+++ b/docs/astro/src/content/docs/zh/guides/particles.mdx
@@ -215,16 +215,16 @@ emitter.colorEasing = ParticleEasing.EaseInOut;
```typescript
import {
- defineSystem, addSystem, Commands, Transform,
+ defineSystem, addStartupSystem, Commands, Transform,
ParticleEmitter, EmitterShape, ParticleEasing
} from 'esengine';
-addSystem(defineSystem(
- [Commands],
+addStartupSystem(defineSystem(
+ [Commands()],
(commands) => {
- commands.spawn(
- Transform.bundle({ position: { x: 400, y: 300, z: 0 } }),
- ParticleEmitter.bundle({
+ commands.spawn()
+ .insert(Transform, { position: { x: 400, y: 300, z: 0 } })
+ .insert(ParticleEmitter, {
rate: 30,
lifetimeMin: 0.5,
lifetimeMax: 1.5,
@@ -244,10 +244,8 @@ addSystem(defineSystem(
colorEasing: ParticleEasing.EaseOut,
gravity: { x: 0, y: -50 },
blendMode: 1,
- }),
- );
- },
- { runCondition: 'once' }
+ });
+ }
));
```