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
fix: sync pause and speed state between editor and SDK app
esengine247492777b19
diff --git a/editor/src/renderer/SharedRenderContext.ts b/editor/src/renderer/SharedRenderContext.tsindex 2a7201361..58d532b96 100644--- a/editor/src/renderer/SharedRenderContext.ts+++ b/editor/src/renderer/SharedRenderContext.ts@@ -302,6 +302,7 @@ export class SharedRenderContext {async exitPlayMode(scene?: import('../types/SceneTypes').SceneData): Promise<void> {this.playMode_ = false;this.paused_ = false;+ this.app_?.setPaused(false);setPlayMode(false);this.clearInputState();@@ -316,10 +317,12 @@ export class SharedRenderContext {pausePlay(): void {this.paused_ = true;+ this.app_?.setPaused(true);}resumePlay(): void {this.paused_ = false;+ this.app_?.setPaused(false);this.lastFrameTime_ = performance.now();}diff --git a/sdk/src/app.ts b/sdk/src/app.tsindex 88cbd71fe..0f2a06754 100644--- a/sdk/src/app.ts+++ b/sdk/src/app.ts@@ -347,11 +347,33 @@ export class App {this.world_.resetQueryPool();this.frame_paused_ = false;- this.runSchedule(Schedule.First);- this.runSchedule(Schedule.PreUpdate);- this.runSchedule(Schedule.Update);- this.runSchedule(Schedule.PostUpdate);- this.runSchedule(Schedule.Last);+ if (this.user_paused_ && !this.step_pending_) {+ this.runSchedule(Schedule.Last);+ } else {+ this.runSchedule(Schedule.First);++ this.fixedAccumulator_ += delta;+ let fixedSteps = 0;+ while (this.fixedAccumulator_ >= this.fixedTimestep_ && fixedSteps < this.maxFixedSteps_) {+ this.fixedAccumulator_ -= this.fixedTimestep_;+ this.runSchedule(Schedule.FixedPreUpdate);+ this.runSchedule(Schedule.FixedUpdate);+ this.runSchedule(Schedule.FixedPostUpdate);+ fixedSteps++;+ }+ if (fixedSteps >= this.maxFixedSteps_) {+ this.fixedAccumulator_ = this.fixedTimestep_;+ }++ this.runSchedule(Schedule.PreUpdate);+ this.runSchedule(Schedule.Update);+ this.runSchedule(Schedule.PostUpdate);+ this.runSchedule(Schedule.Last);++ if (this.step_pending_) {+ this.step_pending_ = false;+ }+ }const REMOVED_BUFFER_RETENTION = 2;this.world_.cleanRemovedBuffer(this.world_.getWorldTick() - REMOVED_BUFFER_RETENTION);