diff --git a/spine-ts/spine-construct3/src/aces.json b/spine-ts/spine-construct3/src/aces.json index 5981d1500..42a551fde 100644 --- a/spine-ts/spine-construct3/src/aces.json +++ b/spine-ts/spine-construct3/src/aces.json @@ -187,6 +187,17 @@ "type": "string" } ] + }, + { + "id": "set-animation-speed", + "scriptName": "SetAnimationSpeed", + "highlight": false, + "params": [ + { + "id": "speed", + "type": "number" + } + ] } ], "expressions": [ diff --git a/spine-ts/spine-construct3/src/c3runtime/actions.ts b/spine-ts/spine-construct3/src/c3runtime/actions.ts index da4ecc6d8..f1817bac5 100644 --- a/spine-ts/spine-construct3/src/c3runtime/actions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/actions.ts @@ -51,6 +51,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts = SetCustomSkin (this: SDKInstanceClass, skinName: string) { this.setCustomSkin(skinName); + }, + + SetAnimationSpeed (this: SDKInstanceClass, speed: number) { + this.setAnimationSpeed(speed); } }; diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index a93173a63..4e1aa2015 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -18,6 +18,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { propScaleY = 1; propFlipX = false; isPlaying = true; + animationSpeed = 1.0; customSkins: Record = {}; textureAtlas?: TextureAtlas; @@ -223,6 +224,10 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { this.skeleton.setupPose(); } + public setAnimationSpeed (speed: number) { + this.animationSpeed = speed; + } + private _setSkin () { const { skeleton } = this; if (!skeleton) return; @@ -261,8 +266,9 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase { if (!skeleton || !state) return; - state.update(delta); - skeleton.update(delta); + const adjustedDelta = delta * this.animationSpeed; + state.update(adjustedDelta); + skeleton.update(adjustedDelta); state.apply(skeleton); skeleton.updateWorldTransform(spine.Physics.update); } diff --git a/spine-ts/spine-construct3/src/lang/en-US.json b/spine-ts/spine-construct3/src/lang/en-US.json index 1785d14f1..5210a6c57 100644 --- a/spine-ts/spine-construct3/src/lang/en-US.json +++ b/spine-ts/spine-construct3/src/lang/en-US.json @@ -261,6 +261,17 @@ "desc": "Name of the custom skin to apply" } } + }, + "set-animation-speed": { + "list-name": "Set animation speed", + "display-text": "Set animation speed to {0}", + "description": "Set the playback speed of animations (1.0 = normal, 2.0 = double speed, 0.5 = half speed)", + "params": { + "speed": { + "name": "Speed", + "desc": "Animation speed multiplier (1.0 is normal speed)" + } + } } }, "expressions": { diff --git a/spine-ts/spine-construct3/src/lang/zh-CN.json b/spine-ts/spine-construct3/src/lang/zh-CN.json index 3f430ccb6..455df74fb 100644 --- a/spine-ts/spine-construct3/src/lang/zh-CN.json +++ b/spine-ts/spine-construct3/src/lang/zh-CN.json @@ -263,6 +263,17 @@ } } }, + "set-animation-speed": { + "list-name": "设置动画速度", + "display-text": "将动画速度设置为{0}", + "description": "设置动画播放速度(1.0 = 正常,2.0 = 两倍速,0.5 = 半速)", + "params": { + "speed": { + "name": "速度", + "desc": "动画速度倍数(1.0为正常速度)" + } + } + }, "expressions": { "double": { "description": "将数字翻倍。",