[csharp] Made Skeleton.scaleX/scaleY private, Skeleton.ScaleY getter takes Bone.yDown into account. Fixes #1386.

This commit is contained in:
badlogic 2019-06-24 14:12:18 +02:00
parent 80971172ef
commit 73fc7867d8
3 changed files with 11 additions and 15 deletions

View File

@ -150,7 +150,7 @@ namespace Spine {
Bone parent = this.parent;
if (parent == null) { // Root bone.
float rotationY = rotation + 90 + shearY, sx = skeleton.scaleX, sy = skeleton.scaleY;
float rotationY = rotation + 90 + shearY, sx = skeleton.ScaleX, sy = skeleton.ScaleY;
a = MathUtils.CosDeg(rotation + shearX) * scaleX * sx;
b = MathUtils.CosDeg(rotationY) * scaleY * sx;
c = MathUtils.SinDeg(rotation + shearX) * scaleX * sy;
@ -212,15 +212,15 @@ namespace Spine {
case TransformMode.NoScale:
case TransformMode.NoScaleOrReflection: {
float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation);
float za = (pa * cos + pb * sin) / skeleton.scaleX;
float zc = (pc * cos + pd * sin) / skeleton.scaleY;
float za = (pa * cos + pb * sin) / skeleton.ScaleX;
float zc = (pc * cos + pd * sin) / skeleton.ScaleY;
float s = (float)Math.Sqrt(za * za + zc * zc);
if (s > 0.00001f) s = 1 / s;
za *= s;
zc *= s;
s = (float)Math.Sqrt(za * za + zc * zc);
if (data.transformMode == TransformMode.NoScale
&& (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s;
&& (pa * pd - pb * pc < 0) != (skeleton.ScaleX < 0 != skeleton.ScaleY < 0)) s = -s;
float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
float zb = MathUtils.Cos(r) * s;
@ -237,10 +237,10 @@ namespace Spine {
}
}
a *= skeleton.scaleX;
b *= skeleton.scaleX;
c *= skeleton.scaleY;
d *= skeleton.scaleY;
a *= skeleton.ScaleX;
b *= skeleton.ScaleX;
c *= skeleton.ScaleY;
d *= skeleton.ScaleY;
}
public void SetToSetupPose () {

View File

@ -44,7 +44,7 @@ namespace Spine {
internal Skin skin;
internal float r = 1, g = 1, b = 1, a = 1;
internal float time;
internal float scaleX = 1, scaleY = 1;
private float scaleX = 1, scaleY = 1;
internal float x, y;
public SkeletonData Data { get { return data; } }
@ -64,7 +64,7 @@ namespace Spine {
public float X { get { return x; } set { x = value; } }
public float Y { get { return y; } set { y = value; } }
public float ScaleX { get { return scaleX; } set { scaleX = value; } }
public float ScaleY { get { return scaleY; } set { scaleY = value; } }
public float ScaleY { get { return scaleY * (Bone.yDown ? -1 : 1); } set { scaleY = value; } }
[Obsolete("Use ScaleX instead. FlipX is when ScaleX is negative.")]
public bool FlipX { get { return scaleX < 0; } set { scaleX = value ? -1f : 1f; } }

View File

@ -77,8 +77,7 @@ namespace Spine {
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
// Flip the skeleton on the y-axis and center it within the viewport
skeleton.ScaleY = -1;
// Center within the viewport
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
skeleton.Y = game.GraphicsDevice.Viewport.Height;
@ -135,7 +134,6 @@ namespace Spine {
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
skeleton.ScaleY = -1;
skeleton.X = game.GraphicsDevice.Viewport.Width / 2 + 200;
skeleton.Y = game.GraphicsDevice.Viewport.Height;
@ -182,7 +180,6 @@ namespace Spine {
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
skeleton.ScaleY = -1;
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
skeleton.Y = game.GraphicsDevice.Viewport.Height;
@ -237,7 +234,6 @@ namespace Spine {
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
skeleton.ScaleY = -1;
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
skeleton.Y = game.GraphicsDevice.Viewport.Height;