Add flip x action and condition.

This commit is contained in:
Davide Tantillo 2025-11-04 16:53:51 +01:00
parent f09ded2744
commit 2e37fb3855
6 changed files with 65 additions and 1 deletions

View File

@ -28,6 +28,11 @@
"type": "string"
}
]
},
{
"id": "is-flipped-x",
"scriptName": "IsFlippedX",
"isTrigger": false
}
],
"actions": [
@ -42,6 +47,17 @@
}
]
},
{
"id": "flip-x",
"scriptName": "FlipX",
"highlight": false,
"params": [
{
"id": "is-flipped-x",
"type": "boolean"
}
]
},
{
"id": "set-animation",
"scriptName": "SetAnimation",

View File

@ -13,6 +13,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
this.setSkin(skinList.split(","));
},
FlipX (this: SDKInstanceClass, isFlippedX: boolean) {
this.flipX(isFlippedX);
},
SetAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false) {
this.setAnimation(track, animation, loop);
},

View File

@ -16,4 +16,7 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds =
&& this.triggeredEventTrack === track
&& this.triggeredEventAnimation === animation;
},
IsFlippedX (this: SDKInstanceClass) {
return this.propFlipX;
},
};

View File

@ -16,6 +16,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
propOffsetAngle = 0;
propScaleX = 1;
propScaleY = 1;
propFlipX = false;
textureAtlas?: TextureAtlas;
renderer?: IRenderer;
@ -97,7 +98,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
this.update(0);
this.skeleton.scaleX = this.propScaleX;
this.skeleton.scaleX = this.propFlipX ? -this.propScaleX : this.propScaleX;
this.skeleton.scaleY = this.propScaleY;
this.skeletonLoaded = true;
@ -117,6 +118,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
this.triggeredEventData = event;
this._trigger(C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds.OnAnimationEvent);
}
public setAnimation (track: number, animation: string, loop = false) {
const trackEntry = this.state?.setAnimation(track, animation, loop);
if (!trackEntry) return;
@ -174,6 +176,13 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
this._setSkin();
}
public flipX (isFlippedX: boolean) {
this.propFlipX = isFlippedX;
if (this.skeleton) {
this.skeleton.scaleX = isFlippedX ? -this.propScaleX : this.propScaleX;
}
}
private _setSkin () {
const { skeleton } = this;
if (!skeleton) return;

View File

@ -98,6 +98,11 @@
"desc": "Track number"
}
}
},
"is-flipped-x": {
"list-name": "Is flipped X",
"display-text": "Is flipped X",
"description": "Check if the skeleton is flipped horizontally"
}
},
"actions": {
@ -117,6 +122,17 @@
}
}
},
"flip-x": {
"list-name": "Flip X",
"display-text": "Set flip X to {0}",
"description": "Flip the skeleton horizontally",
"params": {
"is-flipped-x": {
"name": "Is flipped X",
"desc": "True to flip the skeleton horizontally, false to show normally."
}
}
},
"set-animation": {
"list-name": "Set animation",
"display-text": "Set animation {1} on track {0} with loop {2}",

View File

@ -98,6 +98,11 @@
"desc": "轨道编号"
}
}
},
"is-flipped-x": {
"list-name": "是否水平翻转",
"display-text": "是否水平翻转",
"description": "检查骨架是否水平翻转"
}
},
"actions": {
@ -117,6 +122,17 @@
}
}
},
"flip-x": {
"list-name": "水平翻转",
"display-text": "设置水平翻转为 {0}",
"description": "水平翻转骨架",
"params": {
"is-flipped-x": {
"name": "是否水平翻转",
"desc": "设为true时水平翻转骨架设为false时正常显示。"
}
}
},
"set-animation": {
"list-name": "设置动画",
"display-text": "在轨道{0}上设置动画{1},循环{2}",