Add set-animation-speed.

This commit is contained in:
Davide Tantillo 2025-11-06 10:40:10 +01:00
parent 2fa8601e05
commit 10edf10dce
5 changed files with 45 additions and 2 deletions

View File

@ -187,6 +187,17 @@
"type": "string"
}
]
},
{
"id": "set-animation-speed",
"scriptName": "SetAnimationSpeed",
"highlight": false,
"params": [
{
"id": "speed",
"type": "number"
}
]
}
],
"expressions": [

View File

@ -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);
}
};

View File

@ -18,6 +18,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
propScaleY = 1;
propFlipX = false;
isPlaying = true;
animationSpeed = 1.0;
customSkins: Record<string, Skin> = {};
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);
}

View File

@ -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": {

View File

@ -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": "将数字翻倍。",