mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-02 21:59:09 +08:00
Merge pull request #52 from pharan/master
Inherit rotation and scale in C#
This commit is contained in:
commit
5ba06b952b
@ -61,10 +61,19 @@ namespace Spine {
|
|||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
WorldX = X * parent.M00 + Y * parent.M01 + parent.WorldX;
|
WorldX = X * parent.M00 + Y * parent.M01 + parent.WorldX;
|
||||||
WorldY = X * parent.M10 + Y * parent.M11 + parent.WorldY;
|
WorldY = X * parent.M10 + Y * parent.M11 + parent.WorldY;
|
||||||
WorldScaleX = parent.WorldScaleX * ScaleX;
|
|
||||||
WorldScaleY = parent.WorldScaleY * ScaleY;
|
if(Data.inheritScale) {
|
||||||
WorldRotation = parent.WorldRotation + Rotation;
|
WorldScaleX = parent.WorldScaleX * ScaleX;
|
||||||
|
WorldScaleY = parent.WorldScaleY * ScaleY;
|
||||||
|
} else {
|
||||||
|
WorldScaleX = ScaleX;
|
||||||
|
WorldScaleY = ScaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldRotation = Data.inheritRotation ? parent.WorldRotation + Rotation : Rotation;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
WorldX = X;
|
WorldX = X;
|
||||||
WorldY = Y;
|
WorldY = Y;
|
||||||
WorldScaleX = ScaleX;
|
WorldScaleX = ScaleX;
|
||||||
|
|||||||
@ -36,6 +36,8 @@ namespace Spine {
|
|||||||
public float Rotation { get; set; }
|
public float Rotation { get; set; }
|
||||||
public float ScaleX { get; set; }
|
public float ScaleX { get; set; }
|
||||||
public float ScaleY { get; set; }
|
public float ScaleY { get; set; }
|
||||||
|
public bool inheritScale { get; set; }
|
||||||
|
public bool inheritRotation { get; set; }
|
||||||
|
|
||||||
/** @param parent May be null. */
|
/** @param parent May be null. */
|
||||||
public BoneData (String name, BoneData parent) {
|
public BoneData (String name, BoneData parent) {
|
||||||
|
|||||||
@ -83,6 +83,8 @@ namespace Spine {
|
|||||||
boneData.Rotation = GetFloat(boneMap, "rotation", 0);
|
boneData.Rotation = GetFloat(boneMap, "rotation", 0);
|
||||||
boneData.ScaleX = GetFloat(boneMap, "scaleX", 1);
|
boneData.ScaleX = GetFloat(boneMap, "scaleX", 1);
|
||||||
boneData.ScaleY = GetFloat(boneMap, "scaleY", 1);
|
boneData.ScaleY = GetFloat(boneMap, "scaleY", 1);
|
||||||
|
boneData.inheritScale = GetBoolean (boneMap, "inheritScale", true);
|
||||||
|
boneData.inheritRotation = GetBoolean (boneMap, "inheritRotation", true);
|
||||||
skeletonData.AddBone(boneData);
|
skeletonData.AddBone(boneData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +176,12 @@ namespace Spine {
|
|||||||
return (float)defaultValue;
|
return (float)defaultValue;
|
||||||
return (float)map[name];
|
return (float)map[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool GetBoolean (Dictionary<String, Object> map, String name, bool defaultValue) {
|
||||||
|
if (!map.ContainsKey(name))
|
||||||
|
return (bool)defaultValue;
|
||||||
|
return (bool)map[name];
|
||||||
|
}
|
||||||
|
|
||||||
public static float ToColor (String hexString, int colorIndex) {
|
public static float ToColor (String hexString, int colorIndex) {
|
||||||
if (hexString.Length != 8)
|
if (hexString.Length != 8)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user