mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[csharp] Made Skeleton.scaleX/scaleY private, Skeleton.ScaleY getter takes Bone.yDown into account. Fixes #1386.
This commit is contained in:
parent
80971172ef
commit
73fc7867d8
@ -150,7 +150,7 @@ namespace Spine {
|
|||||||
|
|
||||||
Bone parent = this.parent;
|
Bone parent = this.parent;
|
||||||
if (parent == null) { // Root bone.
|
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;
|
a = MathUtils.CosDeg(rotation + shearX) * scaleX * sx;
|
||||||
b = MathUtils.CosDeg(rotationY) * scaleY * sx;
|
b = MathUtils.CosDeg(rotationY) * scaleY * sx;
|
||||||
c = MathUtils.SinDeg(rotation + shearX) * scaleX * sy;
|
c = MathUtils.SinDeg(rotation + shearX) * scaleX * sy;
|
||||||
@ -212,15 +212,15 @@ namespace Spine {
|
|||||||
case TransformMode.NoScale:
|
case TransformMode.NoScale:
|
||||||
case TransformMode.NoScaleOrReflection: {
|
case TransformMode.NoScaleOrReflection: {
|
||||||
float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation);
|
float cos = MathUtils.CosDeg(rotation), sin = MathUtils.SinDeg(rotation);
|
||||||
float za = (pa * cos + pb * sin) / skeleton.scaleX;
|
float za = (pa * cos + pb * sin) / skeleton.ScaleX;
|
||||||
float zc = (pc * cos + pd * sin) / skeleton.scaleY;
|
float zc = (pc * cos + pd * sin) / skeleton.ScaleY;
|
||||||
float s = (float)Math.Sqrt(za * za + zc * zc);
|
float s = (float)Math.Sqrt(za * za + zc * zc);
|
||||||
if (s > 0.00001f) s = 1 / s;
|
if (s > 0.00001f) s = 1 / s;
|
||||||
za *= s;
|
za *= s;
|
||||||
zc *= s;
|
zc *= s;
|
||||||
s = (float)Math.Sqrt(za * za + zc * zc);
|
s = (float)Math.Sqrt(za * za + zc * zc);
|
||||||
if (data.transformMode == TransformMode.NoScale
|
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 r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
|
||||||
float zb = MathUtils.Cos(r) * s;
|
float zb = MathUtils.Cos(r) * s;
|
||||||
@ -237,10 +237,10 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a *= skeleton.scaleX;
|
a *= skeleton.ScaleX;
|
||||||
b *= skeleton.scaleX;
|
b *= skeleton.ScaleX;
|
||||||
c *= skeleton.scaleY;
|
c *= skeleton.ScaleY;
|
||||||
d *= skeleton.scaleY;
|
d *= skeleton.ScaleY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetToSetupPose () {
|
public void SetToSetupPose () {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace Spine {
|
|||||||
internal Skin skin;
|
internal Skin skin;
|
||||||
internal float r = 1, g = 1, b = 1, a = 1;
|
internal float r = 1, g = 1, b = 1, a = 1;
|
||||||
internal float time;
|
internal float time;
|
||||||
internal float scaleX = 1, scaleY = 1;
|
private float scaleX = 1, scaleY = 1;
|
||||||
internal float x, y;
|
internal float x, y;
|
||||||
|
|
||||||
public SkeletonData Data { get { return data; } }
|
public SkeletonData Data { get { return data; } }
|
||||||
@ -64,7 +64,7 @@ namespace Spine {
|
|||||||
public float X { get { return x; } set { x = value; } }
|
public float X { get { return x; } set { x = value; } }
|
||||||
public float Y { get { return y; } set { y = value; } }
|
public float Y { get { return y; } set { y = value; } }
|
||||||
public float ScaleX { get { return scaleX; } set { scaleX = 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.")]
|
[Obsolete("Use ScaleX instead. FlipX is when ScaleX is negative.")]
|
||||||
public bool FlipX { get { return scaleX < 0; } set { scaleX = value ? -1f : 1f; } }
|
public bool FlipX { get { return scaleX < 0; } set { scaleX = value ? -1f : 1f; } }
|
||||||
|
|||||||
@ -77,8 +77,7 @@ namespace Spine {
|
|||||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||||
state = new AnimationState(stateData);
|
state = new AnimationState(stateData);
|
||||||
|
|
||||||
// Flip the skeleton on the y-axis and center it within the viewport
|
// Center within the viewport
|
||||||
skeleton.ScaleY = -1;
|
|
||||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
||||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||||
|
|
||||||
@ -135,7 +134,6 @@ namespace Spine {
|
|||||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||||
state = new AnimationState(stateData);
|
state = new AnimationState(stateData);
|
||||||
|
|
||||||
skeleton.ScaleY = -1;
|
|
||||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2 + 200;
|
skeleton.X = game.GraphicsDevice.Viewport.Width / 2 + 200;
|
||||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||||
|
|
||||||
@ -182,7 +180,6 @@ namespace Spine {
|
|||||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||||
state = new AnimationState(stateData);
|
state = new AnimationState(stateData);
|
||||||
|
|
||||||
skeleton.ScaleY = -1;
|
|
||||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
||||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||||
|
|
||||||
@ -237,7 +234,6 @@ namespace Spine {
|
|||||||
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
|
||||||
state = new AnimationState(stateData);
|
state = new AnimationState(stateData);
|
||||||
|
|
||||||
skeleton.ScaleY = -1;
|
|
||||||
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
|
||||||
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
skeleton.Y = game.GraphicsDevice.Viewport.Height;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user