From 61b2b0291d2e1604064d9cc61b14318bf88b3b44 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Wed, 18 Mar 2026 14:43:00 +0100 Subject: [PATCH] Add SetIgnoreGlobalTimeScale action and respective expression. --- spine-ts/spine-construct3/src/aces.json | 17 +++++++++++++++++ .../spine-construct3/src/c3runtime/actions.ts | 4 ++++ .../src/c3runtime/expressions.ts | 4 ++++ .../spine-construct3/src/c3runtime/instance.ts | 6 +++++- spine-ts/spine-construct3/src/lang/en-US.json | 15 +++++++++++++++ spine-ts/spine-construct3/src/lang/zh-CN.json | 15 +++++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) diff --git a/spine-ts/spine-construct3/src/aces.json b/spine-ts/spine-construct3/src/aces.json index 3374fd055..2b9c6a736 100644 --- a/spine-ts/spine-construct3/src/aces.json +++ b/spine-ts/spine-construct3/src/aces.json @@ -300,6 +300,17 @@ } ] }, + { + "id": "set-ignore-global-time-scale", + "scriptName": "SetIgnoreGlobalTimeScale", + "highlight": false, + "params": [ + { + "id": "ignore-global-time-scale", + "type": "boolean" + } + ] + }, { "id": "set-animation-time", "scriptName": "SetAnimationTime", @@ -835,6 +846,12 @@ "highlight": false, "returnType": "number" }, + { + "id": "ignore-global-time-scale", + "expressionName": "IgnoreGlobalTimeScale", + "highlight": false, + "returnType": "number" + }, { "id": "current-animation-start", "expressionName": "CurrentAnimationStart", diff --git a/spine-ts/spine-construct3/src/c3runtime/actions.ts b/spine-ts/spine-construct3/src/c3runtime/actions.ts index aec182b46..465354306 100644 --- a/spine-ts/spine-construct3/src/c3runtime/actions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/actions.ts @@ -89,6 +89,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts = this.setAnimationSpeed(timeScale); }, + SetIgnoreGlobalTimeScale (this: SDKInstanceClass, ignoreGlobalTimeScale: boolean) { + this.ignoreGlobalTimeScale = ignoreGlobalTimeScale; + }, + SetAnimationTime (this: SDKInstanceClass, track: number, time: number, units: 0 | 1) { this.setAnimationTime(units, time, track); }, diff --git a/spine-ts/spine-construct3/src/c3runtime/expressions.ts b/spine-ts/spine-construct3/src/c3runtime/expressions.ts index e11a5f1cc..954c41a62 100644 --- a/spine-ts/spine-construct3/src/c3runtime/expressions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/expressions.ts @@ -116,6 +116,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Exps = return this.state?.timeScale ?? 1; }, + IgnoreGlobalTimeScale (this: SpineC3Instance) { + return this.ignoreGlobalTimeScale ? 1 : 0; + }, + CurrentAnimationStart (this: SpineC3Instance, trackIndex: number) { const track = this.state?.tracks[trackIndex]; return track?.animationStart ?? 0; diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index 21475c6e0..a518bdedc 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -68,12 +68,14 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { skeletonLoading = false; skeleton?: Skeleton; state?: AnimationState; + ignoreGlobalTimeScale = false; public triggeredEventTrack = -1; public triggeredEventAnimation = ""; public triggeredEventName = ""; public triggeredEventData?: Event & { track: number, animation: string }; + private time = new spine.TimeKeeper(); private assetLoader: AssetLoader; private skeletonRenderer?: C3RendererRuntime; private matrix: C3Matrix; @@ -148,6 +150,8 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { } _tick (): void { + this.time.update(); + const { renderer } = this; if (!renderer) return; @@ -172,7 +176,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { this.updateCollisionSprite(); - if (this.isPlaying) this.update(this.dt); + if (this.isPlaying) this.update(this.ignoreGlobalTimeScale ? this.time.delta : this.dt); } private update (delta: number) { diff --git a/spine-ts/spine-construct3/src/lang/en-US.json b/spine-ts/spine-construct3/src/lang/en-US.json index 5bbb0d3c5..ae17bd4bb 100644 --- a/spine-ts/spine-construct3/src/lang/en-US.json +++ b/spine-ts/spine-construct3/src/lang/en-US.json @@ -379,6 +379,17 @@ } } }, + "set-ignore-global-time-scale": { + "list-name": "Set ignore global time scale", + "display-text": "Set ignore global time scale to {0}", + "description": "Set whether this instance ignores the global time scale set in Construct 3", + "params": { + "ignore-global-time-scale": { + "name": "Ignore global time scale", + "desc": "True to ignore the global time scale, false to use it." + } + } + }, "set-animation-time": { "list-name": "Set animation time", "display-text": "Set track {0} animation time to {1} ({2})", @@ -909,6 +920,10 @@ "description": "Get the current animation time scale (speed multiplier).", "translated-name": "TimeScale" }, + "ignore-global-time-scale": { + "description": "Get whether this instance ignores the global time scale (1 = ignoring, 0 = not ignoring).", + "translated-name": "IgnoreGlobalTimeScale" + }, "current-animation-start": { "description": "Get the start time of the current animation on the specified track.", "translated-name": "CurrentAnimationStart", diff --git a/spine-ts/spine-construct3/src/lang/zh-CN.json b/spine-ts/spine-construct3/src/lang/zh-CN.json index a83c2bdd9..50c80d79c 100644 --- a/spine-ts/spine-construct3/src/lang/zh-CN.json +++ b/spine-ts/spine-construct3/src/lang/zh-CN.json @@ -379,6 +379,17 @@ } } }, + "set-ignore-global-time-scale": { + "list-name": "设置忽略全局时间缩放", + "display-text": "将忽略全局时间缩放设置为{0}", + "description": "设置此实例是否忽略Construct 3中设置的全局时间缩放", + "params": { + "ignore-global-time-scale": { + "name": "忽略全局时间缩放", + "desc": "设置为true则忽略全局时间缩放,设置为false则使用全局时间缩放。" + } + } + }, "set-animation-time": { "list-name": "设置动画时间", "display-text": "将轨道{0}的动画时间设置为{1}({2})", @@ -909,6 +920,10 @@ "description": "获取当前动画时间缩放(速度倍数)。", "translated-name": "TimeScale" }, + "ignore-global-time-scale": { + "description": "获取此实例是否忽略全局时间缩放(1 = 忽略,0 = 不忽略)。", + "translated-name": "IgnoreGlobalTimeScale" + }, "current-animation-start": { "description": "获取指定轨道上当前动画的开始时间。", "translated-name": "CurrentAnimationStart",