mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Add flip x action and condition.
This commit is contained in:
parent
f09ded2744
commit
2e37fb3855
@ -28,6 +28,11 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "is-flipped-x",
|
||||||
|
"scriptName": "IsFlippedX",
|
||||||
|
"isTrigger": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actions": [
|
"actions": [
|
||||||
@ -42,6 +47,17 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "flip-x",
|
||||||
|
"scriptName": "FlipX",
|
||||||
|
"highlight": false,
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"id": "is-flipped-x",
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "set-animation",
|
"id": "set-animation",
|
||||||
"scriptName": "SetAnimation",
|
"scriptName": "SetAnimation",
|
||||||
|
|||||||
@ -13,6 +13,10 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Acts =
|
|||||||
this.setSkin(skinList.split(","));
|
this.setSkin(skinList.split(","));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
FlipX (this: SDKInstanceClass, isFlippedX: boolean) {
|
||||||
|
this.flipX(isFlippedX);
|
||||||
|
},
|
||||||
|
|
||||||
SetAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false) {
|
SetAnimation (this: SDKInstanceClass, track: number, animation: string, loop = false) {
|
||||||
this.setAnimation(track, animation, loop);
|
this.setAnimation(track, animation, loop);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -16,4 +16,7 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds =
|
|||||||
&& this.triggeredEventTrack === track
|
&& this.triggeredEventTrack === track
|
||||||
&& this.triggeredEventAnimation === animation;
|
&& this.triggeredEventAnimation === animation;
|
||||||
},
|
},
|
||||||
|
IsFlippedX (this: SDKInstanceClass) {
|
||||||
|
return this.propFlipX;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
|||||||
propOffsetAngle = 0;
|
propOffsetAngle = 0;
|
||||||
propScaleX = 1;
|
propScaleX = 1;
|
||||||
propScaleY = 1;
|
propScaleY = 1;
|
||||||
|
propFlipX = false;
|
||||||
|
|
||||||
textureAtlas?: TextureAtlas;
|
textureAtlas?: TextureAtlas;
|
||||||
renderer?: IRenderer;
|
renderer?: IRenderer;
|
||||||
@ -97,7 +98,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
|||||||
|
|
||||||
this.update(0);
|
this.update(0);
|
||||||
|
|
||||||
this.skeleton.scaleX = this.propScaleX;
|
this.skeleton.scaleX = this.propFlipX ? -this.propScaleX : this.propScaleX;
|
||||||
this.skeleton.scaleY = this.propScaleY;
|
this.skeleton.scaleY = this.propScaleY;
|
||||||
|
|
||||||
this.skeletonLoaded = true;
|
this.skeletonLoaded = true;
|
||||||
@ -117,6 +118,7 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
|||||||
this.triggeredEventData = event;
|
this.triggeredEventData = event;
|
||||||
this._trigger(C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds.OnAnimationEvent);
|
this._trigger(C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds.OnAnimationEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setAnimation (track: number, animation: string, loop = false) {
|
public setAnimation (track: number, animation: string, loop = false) {
|
||||||
const trackEntry = this.state?.setAnimation(track, animation, loop);
|
const trackEntry = this.state?.setAnimation(track, animation, loop);
|
||||||
if (!trackEntry) return;
|
if (!trackEntry) return;
|
||||||
@ -174,6 +176,13 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
|
|||||||
this._setSkin();
|
this._setSkin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public flipX (isFlippedX: boolean) {
|
||||||
|
this.propFlipX = isFlippedX;
|
||||||
|
if (this.skeleton) {
|
||||||
|
this.skeleton.scaleX = isFlippedX ? -this.propScaleX : this.propScaleX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _setSkin () {
|
private _setSkin () {
|
||||||
const { skeleton } = this;
|
const { skeleton } = this;
|
||||||
if (!skeleton) return;
|
if (!skeleton) return;
|
||||||
|
|||||||
@ -98,6 +98,11 @@
|
|||||||
"desc": "Track number"
|
"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": {
|
"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": {
|
"set-animation": {
|
||||||
"list-name": "Set animation",
|
"list-name": "Set animation",
|
||||||
"display-text": "Set animation {1} on track {0} with loop {2}",
|
"display-text": "Set animation {1} on track {0} with loop {2}",
|
||||||
|
|||||||
@ -98,6 +98,11 @@
|
|||||||
"desc": "轨道编号"
|
"desc": "轨道编号"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"is-flipped-x": {
|
||||||
|
"list-name": "是否水平翻转",
|
||||||
|
"display-text": "是否水平翻转",
|
||||||
|
"description": "检查骨架是否水平翻转"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"actions": {
|
"actions": {
|
||||||
@ -117,6 +122,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flip-x": {
|
||||||
|
"list-name": "水平翻转",
|
||||||
|
"display-text": "设置水平翻转为 {0}",
|
||||||
|
"description": "水平翻转骨架",
|
||||||
|
"params": {
|
||||||
|
"is-flipped-x": {
|
||||||
|
"name": "是否水平翻转",
|
||||||
|
"desc": "设为true时水平翻转骨架,设为false时正常显示。"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"set-animation": {
|
"set-animation": {
|
||||||
"list-name": "设置动画",
|
"list-name": "设置动画",
|
||||||
"display-text": "在轨道{0}上设置动画{1},循环{2}",
|
"display-text": "在轨道{0}上设置动画{1},循环{2}",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user