[as3] Ported flipX/flipY -> scaleX/scaleY change. See #1142.

This commit is contained in:
badlogic 2018-07-24 14:39:54 +02:00
parent 486fa7eebf
commit fb67ada3d8
6 changed files with 24 additions and 44 deletions

View File

@ -92,31 +92,19 @@ package spine {
var rotationY : Number = 0, la : Number = 0, lb : Number = 0, lc : Number = 0, ld : Number = 0; var rotationY : Number = 0, la : Number = 0, lb : Number = 0, lc : Number = 0, ld : Number = 0;
var sin : Number = 0, cos : Number = 0; var sin : Number = 0, cos : Number = 0;
var s : Number = 0; var s : Number = 0;
var sx : Number = _skeleton.scaleX;
var sy : Number = _skeleton.scaleY * (yDown ? -1 : 1);
var parent : Bone = _parent; var parent : Bone = _parent;
if (!parent) { // Root bone. if (!parent) { // Root bone.
rotationY = rotation + 90 + shearY; rotationY = rotation + 90 + shearY;
la = MathUtils.cosDeg(rotation + shearX) * scaleX; var skeleton : Skeleton = _skeleton;
lb = MathUtils.cosDeg(rotationY) * scaleY; this.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx;
lc = MathUtils.sinDeg(rotation + shearX) * scaleX; this.b = MathUtils.cosDeg(rotationY) * scaleY * sy;
ld = MathUtils.sinDeg(rotationY) * scaleY; this.c = MathUtils.sinDeg(rotation + shearX) * scaleX * sx;
var skeleton : Skeleton = _skeleton; this.d = MathUtils.sinDeg(rotationY) * scaleY * sy;
if (skeleton.flipX) { worldX = x * sx + skeleton.x;
x = -x; worldY = y * sy + skeleton.y;
la = -la;
lb = -lb;
}
if (skeleton.flipY != yDown) {
y = -y;
lc = -lc;
ld = -ld;
}
this.a = la;
this.b = lb;
this.c = lc;
this.d = ld;
worldX = x + skeleton.x;
worldY = y + skeleton.y;
return; return;
} }
@ -174,8 +162,8 @@ package spine {
case TransformMode.noScaleOrReflection: { case TransformMode.noScaleOrReflection: {
cos = MathUtils.cosDeg(rotation); cos = MathUtils.cosDeg(rotation);
sin = MathUtils.sinDeg(rotation); sin = MathUtils.sinDeg(rotation);
var za : Number = pa * cos + pb * sin; var za : Number = (pa * cos + pb * sin) / sx;
var zc : Number = pc * cos + pd * sin; var zc : Number = (pc * cos + pd * sin) / sy;
s = Math.sqrt(za * za + zc * zc); s = Math.sqrt(za * za + zc * zc);
if (s > 0.00001) s = 1 / s; if (s > 0.00001) s = 1 / s;
za *= s; za *= s;
@ -187,26 +175,18 @@ package spine {
la = MathUtils.cosDeg(shearX) * scaleX; la = MathUtils.cosDeg(shearX) * scaleX;
lb = MathUtils.cosDeg(90 + shearY) * scaleY; lb = MathUtils.cosDeg(90 + shearY) * scaleY;
lc = MathUtils.sinDeg(shearX) * scaleX; lc = MathUtils.sinDeg(shearX) * scaleX;
ld = MathUtils.sinDeg(90 + shearY) * scaleY; ld = MathUtils.sinDeg(90 + shearY) * scaleY;
if (this.data.transformMode != TransformMode.noScaleOrReflection ? pa * pd - pb * pc < 0 : this.skeleton.flipX != this.skeleton.flipY) {
zb = -zb;
zd = -zd;
}
this.a = za * la + zb * lc; this.a = za * la + zb * lc;
this.b = za * lb + zb * ld; this.b = za * lb + zb * ld;
this.c = zc * la + zd * lc; this.c = zc * la + zd * lc;
this.d = zc * lb + zd * ld; this.d = zc * lb + zd * ld;
return; break;
} }
} }
if (_skeleton.flipX) { this.a *= sx;
this.a = -this.a; this.b *= sx;
this.b = -this.b; this.c *= sy;
} this.d *= sy;
if (_skeleton.flipY != yDown) {
this.c = -this.c;
this.d = -this.d;
}
} }
public function setToSetupPose() : void { public function setToSetupPose() : void {

View File

@ -50,7 +50,7 @@ package spine {
private var _skin : Skin; private var _skin : Skin;
public var color : Color = new Color(1, 1, 1, 1); public var color : Color = new Color(1, 1, 1, 1);
public var time : Number = 0; public var time : Number = 0;
public var flipX : Boolean, flipY : Boolean; public var scaleX : Number = 1, scaleY : Number = 1;
public var x : Number = 0, y : Number = 0; public var x : Number = 0, y : Number = 0;
public function Skeleton(data : SkeletonData) { public function Skeleton(data : SkeletonData) {

View File

@ -146,14 +146,14 @@ package spine.flash {
wrapper.transform.colorTransform = colorTransform; wrapper.transform.colorTransform = colorTransform;
var bone : Bone = slot.bone; var bone : Bone = slot.bone;
var flipX : int = skeleton.flipX ? -1 : 1; var scaleX : Number = skeleton.scaleX;
var flipY : int = skeleton.flipY ? -1 : 1; var scaleY : Number = skeleton.scaleY;
wrapper.x = bone.worldX; wrapper.x = bone.worldX;
wrapper.y = bone.worldY; wrapper.y = bone.worldY;
wrapper.rotation = bone.worldRotationX * flipX * flipY; wrapper.rotation = bone.worldRotationX * scaleX * scaleX;
wrapper.scaleX = bone.worldScaleX * flipX; wrapper.scaleX = bone.worldScaleX * scaleX;
wrapper.scaleY = bone.worldScaleY * flipY; wrapper.scaleY = bone.worldScaleY * scaleY;
addChild(wrapper); addChild(wrapper);
} }
} }