mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Add set-animation-speed.
This commit is contained in:
parent
2fa8601e05
commit
10edf10dce
@ -187,6 +187,17 @@
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "set-animation-speed",
|
||||
"scriptName": "SetAnimationSpeed",
|
||||
"highlight": false,
|
||||
"params": [
|
||||
{
|
||||
"id": "speed",
|
||||
"type": "number"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"expressions": [
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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": {
|
||||
|
||||
@ -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": "将数字翻倍。",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user