From 2e37fb3855ee7ce2d84807d823d59730e22b4b71 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Tue, 4 Nov 2025 16:53:51 +0100 Subject: [PATCH] Add flip x action and condition. --- spine-ts/spine-construct3/src/aces.json | 16 ++++++++++++++++ .../spine-construct3/src/c3runtime/actions.ts | 4 ++++ .../spine-construct3/src/c3runtime/conditions.ts | 3 +++ .../spine-construct3/src/c3runtime/instance.ts | 11 ++++++++++- spine-ts/spine-construct3/src/lang/en-US.json | 16 ++++++++++++++++ spine-ts/spine-construct3/src/lang/zh-CN.json | 16 ++++++++++++++++ 6 files changed, 65 insertions(+), 1 deletion(-) diff --git a/spine-ts/spine-construct3/src/aces.json b/spine-ts/spine-construct3/src/aces.json index 5f6ac1a4e..3d3723a90 100644 --- a/spine-ts/spine-construct3/src/aces.json +++ b/spine-ts/spine-construct3/src/aces.json @@ -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", diff --git a/spine-ts/spine-construct3/src/c3runtime/actions.ts b/spine-ts/spine-construct3/src/c3runtime/actions.ts index 2f195b0b8..74bd39404 100644 --- a/spine-ts/spine-construct3/src/c3runtime/actions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/actions.ts @@ -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); }, diff --git a/spine-ts/spine-construct3/src/c3runtime/conditions.ts b/spine-ts/spine-construct3/src/c3runtime/conditions.ts index 5f0c5cb63..9fd515aa0 100644 --- a/spine-ts/spine-construct3/src/c3runtime/conditions.ts +++ b/spine-ts/spine-construct3/src/c3runtime/conditions.ts @@ -16,4 +16,7 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds = && this.triggeredEventTrack === track && this.triggeredEventAnimation === animation; }, + IsFlippedX (this: SDKInstanceClass) { + return this.propFlipX; + }, }; diff --git a/spine-ts/spine-construct3/src/c3runtime/instance.ts b/spine-ts/spine-construct3/src/c3runtime/instance.ts index 9b11898d6..7a196af99 100644 --- a/spine-ts/spine-construct3/src/c3runtime/instance.ts +++ b/spine-ts/spine-construct3/src/c3runtime/instance.ts @@ -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; diff --git a/spine-ts/spine-construct3/src/lang/en-US.json b/spine-ts/spine-construct3/src/lang/en-US.json index a8c61a277..f4dc98061 100644 --- a/spine-ts/spine-construct3/src/lang/en-US.json +++ b/spine-ts/spine-construct3/src/lang/en-US.json @@ -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}", diff --git a/spine-ts/spine-construct3/src/lang/zh-CN.json b/spine-ts/spine-construct3/src/lang/zh-CN.json index efb5aea3a..1bfb084db 100644 --- a/spine-ts/spine-construct3/src/lang/zh-CN.json +++ b/spine-ts/spine-construct3/src/lang/zh-CN.json @@ -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}",