diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs index ebf24ed42..cbfe409a3 100644 --- a/spine-csharp/src/Animation.cs +++ b/spine-csharp/src/Animation.cs @@ -565,15 +565,15 @@ namespace Spine { } } + override public int PropertyId { + get { return ((int)TimelineType.TwoColor << 24) + slotIndex; } + } + public TwoColorTimeline (int frameCount) : base(frameCount) { frames = new float[frameCount * ENTRIES]; } - override public int PropertyId { - get { return ((int)TimelineType.TwoColor << 24) + slotIndex; } - } - /// Sets the time and value of the specified keyframe. public void SetFrame (int frameIndex, float time, float r, float g, float b, float a, float r2, float g2, float b2) { frameIndex *= ENTRIES; diff --git a/spine-csharp/src/Bone.cs b/spine-csharp/src/Bone.cs index b329a3c47..e9367986a 100644 --- a/spine-csharp/src/Bone.cs +++ b/spine-csharp/src/Bone.cs @@ -65,19 +65,49 @@ namespace Spine { public ExposedList Children { get { return children; } } /// The local X translation. public float X { get { return x; } set { x = value; } } + /// The local Y translation. public float Y { get { return y; } set { y = value; } } + /// The local rotation. public float Rotation { get { return rotation; } set { rotation = value; } } + + /// The local scaleX. + public float ScaleX { get { return scaleX; } set { scaleX = value; } } + + /// The local scaleY. + public float ScaleY { get { return scaleY; } set { scaleY = value; } } + + /// The local shearX. + public float ShearX { get { return shearX; } set { shearX = value; } } + + /// The local shearY. + public float ShearY { get { return shearY; } set { shearY = value; } } + /// The rotation, as calculated by any constraints. public float AppliedRotation { get { return arotation; } set { arotation = value; } } - public float ScaleX { get { return scaleX; } set { scaleX = value; } } - public float ScaleY { get { return scaleY; } set { scaleY = value; } } - public float ShearX { get { return shearX; } set { shearX = value; } } - public float ShearY { get { return shearY; } set { shearY = value; } } + + /// The applied local x translation. + public float AX { get { return ax; } set { ax = value; } } + + /// The applied local y translation. + public float AY { get { return ay; } set { ay = value; } } + + /// The applied local scaleX. + public float AScaleX { get { return ascaleX; } set { ascaleX = value; } } + + /// The applied local scaleY. + public float AScaleY { get { return ascaleY; } set { ascaleY = value; } } + + /// The applied local shearX. + public float AShearX { get { return ashearX; } set { ashearX = value; } } + + /// The applied local shearY. + public float AShearY { get { return ashearY; } set { ashearY = value; } } public float A { get { return a; } } public float B { get { return b; } } public float C { get { return c; } } public float D { get { return d; } } + public float WorldX { get { return worldX; } } public float WorldY { get { return worldY; } } public float WorldRotationX { get { return MathUtils.Atan2(c, a) * MathUtils.RadDeg; } } @@ -337,6 +367,10 @@ namespace Spine { return MathUtils.Atan2(cos * c + sin * d, cos * a + sin * b) * MathUtils.RadDeg; } + /// + /// Rotates the world transform the specified amount and sets isAppliedValid to false. + /// + /// Degrees. public void RotateWorld (float degrees) { float a = this.a, b = this.b, c = this.c, d = this.d; float cos = MathUtils.CosDeg(degrees), sin = MathUtils.SinDeg(degrees); @@ -347,7 +381,7 @@ namespace Spine { appliedValid = false; } - override public String ToString () { + override public string ToString () { return data.name; } } diff --git a/spine-csharp/src/BoneData.cs b/spine-csharp/src/BoneData.cs index 3933374fd..cb7e31787 100644 --- a/spine-csharp/src/BoneData.cs +++ b/spine-csharp/src/BoneData.cs @@ -33,32 +33,49 @@ using System; namespace Spine { public class BoneData { internal int index; - internal String name; + internal string name; internal BoneData parent; internal float length; internal float x, y, rotation, scaleX = 1, scaleY = 1, shearX, shearY; internal TransformMode transformMode = TransformMode.Normal; - //internal bool inheritRotation = true, inheritScale = true; + + /// The index of the bone in Skeleton.Bones + public int Index { get { return index; } } + + /// The name of the bone, which is unique within the skeleton. + public string Name { get { return name; } } /// May be null. - public int Index { get { return index; } } - public String Name { get { return name; } } public BoneData Parent { get { return parent; } } - public float Length { get { return length; } set { length = value; } } - public float X { get { return x; } set { x = value; } } - public float Y { get { return y; } set { y = value; } } - public float Rotation { get { return rotation; } set { rotation = value; } } - public float ScaleX { get { return scaleX; } set { scaleX = value; } } - public float ScaleY { get { return scaleY; } set { scaleY = value; } } - public float ShearX { get { return shearX; } set { shearX = value; } } - public float ShearY { get { return shearY; } set { shearY = value; } } - public TransformMode TransformMode { get { return transformMode; } set { transformMode = value; } } -// public bool InheritRotation { get { return inheritRotation; } set { inheritRotation = value; } } -// public bool InheritScale { get { return inheritScale; } set { inheritScale = value; } } + public float Length { get { return length; } set { length = value; } } + + /// Local X translation. + public float X { get { return x; } set { x = value; } } + + /// Local Y translation. + public float Y { get { return y; } set { y = value; } } + + /// Local rotation. + public float Rotation { get { return rotation; } set { rotation = value; } } + + /// Local scaleX. + public float ScaleX { get { return scaleX; } set { scaleX = value; } } + + /// Local scaleY. + public float ScaleY { get { return scaleY; } set { scaleY = value; } } + + /// Local shearX. + public float ShearX { get { return shearX; } set { shearX = value; } } + + /// Local shearY. + public float ShearY { get { return shearY; } set { shearY = value; } } + + /// The transform mode for how parent world transforms affect this bone. + public TransformMode TransformMode { get { return transformMode; } set { transformMode = value; } } /// May be null. - public BoneData (int index, String name, BoneData parent) { + public BoneData (int index, string name, BoneData parent) { if (index < 0) throw new ArgumentException("index must be >= 0", "index"); if (name == null) throw new ArgumentNullException("name", "name cannot be null."); this.index = index; @@ -66,14 +83,14 @@ namespace Spine { this.parent = parent; } - override public String ToString () { + override public string ToString () { return name; } } [Flags] public enum TransformMode { - //0000 0FSR + //0000 0 Flip Scale Rotation Normal = 0, // 0000 OnlyTranslation = 7, // 0111 NoRotationOrReflection = 1, // 0001 diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index 6b012d634..d9cd7d625 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -339,7 +339,7 @@ namespace Spine { } /// May be null. - public Bone FindBone (String boneName) { + public Bone FindBone (string boneName) { if (boneName == null) throw new ArgumentNullException("boneName", "boneName cannot be null."); var bones = this.bones; var bonesItems = bones.Items; @@ -351,7 +351,7 @@ namespace Spine { } /// -1 if the bone was not found. - public int FindBoneIndex (String boneName) { + public int FindBoneIndex (string boneName) { if (boneName == null) throw new ArgumentNullException("boneName", "boneName cannot be null."); var bones = this.bones; var bonesItems = bones.Items; @@ -361,7 +361,7 @@ namespace Spine { } /// May be null. - public Slot FindSlot (String slotName) { + public Slot FindSlot (string slotName) { if (slotName == null) throw new ArgumentNullException("slotName", "slotName cannot be null."); var slots = this.slots; var slotsItems = slots.Items; @@ -373,7 +373,7 @@ namespace Spine { } /// -1 if the bone was not found. - public int FindSlotIndex (String slotName) { + public int FindSlotIndex (string slotName) { if (slotName == null) throw new ArgumentNullException("slotName", "slotName cannot be null."); var slots = this.slots; var slotsItems = slots.Items; @@ -383,7 +383,7 @@ namespace Spine { } /// Sets a skin by name (see SetSkin). - public void SetSkin (String skinName) { + public void SetSkin (string skinName) { Skin skin = data.FindSkin(skinName); if (skin == null) throw new ArgumentException("Skin not found: " + skinName, "skinName"); SetSkin(skin); @@ -401,7 +401,7 @@ namespace Spine { ExposedList slots = this.slots; for (int i = 0, n = slots.Count; i < n; i++) { Slot slot = slots.Items[i]; - String name = slot.data.attachmentName; + string name = slot.data.attachmentName; if (name != null) { Attachment attachment = newSkin.GetAttachment(i, name); if (attachment != null) slot.Attachment = attachment; @@ -413,12 +413,12 @@ namespace Spine { } /// May be null. - public Attachment GetAttachment (String slotName, String attachmentName) { + public Attachment GetAttachment (string slotName, string attachmentName) { return GetAttachment(data.FindSlotIndex(slotName), attachmentName); } /// May be null. - public Attachment GetAttachment (int slotIndex, String attachmentName) { + public Attachment GetAttachment (int slotIndex, string attachmentName) { if (attachmentName == null) throw new ArgumentNullException("attachmentName", "attachmentName cannot be null."); if (skin != null) { Attachment attachment = skin.GetAttachment(slotIndex, attachmentName); @@ -429,7 +429,7 @@ namespace Spine { } /// May be null. - public void SetAttachment (String slotName, String attachmentName) { + public void SetAttachment (string slotName, string attachmentName) { if (slotName == null) throw new ArgumentNullException("slotName", "slotName cannot be null."); ExposedList slots = this.slots; for (int i = 0, n = slots.Count; i < n; i++) { @@ -448,7 +448,7 @@ namespace Spine { } /// May be null. - public IkConstraint FindIkConstraint (String constraintName) { + public IkConstraint FindIkConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); ExposedList ikConstraints = this.ikConstraints; for (int i = 0, n = ikConstraints.Count; i < n; i++) { @@ -459,7 +459,7 @@ namespace Spine { } /// May be null. - public TransformConstraint FindTransformConstraint (String constraintName) { + public TransformConstraint FindTransformConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); ExposedList transformConstraints = this.transformConstraints; for (int i = 0, n = transformConstraints.Count; i < n; i++) { @@ -470,7 +470,7 @@ namespace Spine { } /// May be null. - public PathConstraint FindPathConstraint (String constraintName) { + public PathConstraint FindPathConstraint (string constraintName) { if (constraintName == null) throw new ArgumentNullException("constraintName", "constraintName cannot be null."); ExposedList pathConstraints = this.pathConstraints; for (int i = 0, n = pathConstraints.Count; i < n; i++) { @@ -493,10 +493,10 @@ namespace Spine { public void GetBounds (out float x, out float y, out float width, out float height, ref float[] vertexBuffer) { float[] temp = vertexBuffer; temp = temp ?? new float[8]; - var drawOrder = this.drawOrder; + var drawOrderItems = this.drawOrder.Items; float minX = int.MaxValue, minY = int.MaxValue, maxX = int.MinValue, maxY = int.MinValue; - for (int i = 0, n = drawOrder.Count; i < n; i++) { - Slot slot = drawOrder.Items[i]; + for (int i = 0, n = this.drawOrder.Count; i < n; i++) { + Slot slot = drawOrderItems[i]; int verticesLength = 0; float[] vertices = null; Attachment attachment = slot.attachment; @@ -504,7 +504,7 @@ namespace Spine { if (regionAttachment != null) { verticesLength = 8; if (temp.Length < 8) temp = new float[8]; - regionAttachment.ComputeWorldVertices(slot.bone, temp); + regionAttachment.ComputeWorldVertices(slot.bone, temp, 0); } else { var meshAttachment = attachment as MeshAttachment; if (meshAttachment != null) { diff --git a/spine-csharp/src/SkeletonJson.cs b/spine-csharp/src/SkeletonJson.cs index 43e091ddf..c16a3ceec 100644 --- a/spine-csharp/src/SkeletonJson.cs +++ b/spine-csharp/src/SkeletonJson.cs @@ -480,9 +480,9 @@ namespace Spine { timeline.slotIndex = slotIndex; int frameIndex = 0; - foreach (Dictionary valueMap in values) { + foreach (Dictionary valueMap in values) { float time = (float)valueMap["time"]; - String c = (String)valueMap["color"]; + string c = (string)valueMap["color"]; timeline.SetFrame(frameIndex, time, ToColor(c, 0), ToColor(c, 1), ToColor(c, 2), ToColor(c, 3)); ReadCurve(valueMap, timeline, frameIndex); frameIndex++; @@ -495,17 +495,17 @@ namespace Spine { timeline.slotIndex = slotIndex; int frameIndex = 0; - foreach (Dictionary valueMap in values) { + foreach (Dictionary valueMap in values) { float time = (float)valueMap["time"]; - String c = (String)valueMap["light"]; - String c2 = (String)valueMap["dark"]; - timeline.SetFrame(frameIndex, time, ToColor(c, 0), ToColor(c, 1), ToColor(c, 2), ToColor(c, 3), - ToColor(c2, 0), ToColor(c2, 1), ToColor(c2, 2)); + string light = (string)valueMap["light"]; + string dark = (string)valueMap["dark"]; + timeline.SetFrame(frameIndex, time, ToColor(light, 0), ToColor(light, 1), ToColor(light, 2), ToColor(light, 3), + ToColor(dark, 0), ToColor(dark, 1), ToColor(dark, 2)); ReadCurve(valueMap, timeline, frameIndex); frameIndex++; } timelines.Add(timeline); - duration = Math.Max(duration, timeline.frames[(timeline.FrameCount - 1) * ColorTimeline.ENTRIES]); + duration = Math.Max(duration, timeline.frames[(timeline.FrameCount - 1) * TwoColorTimeline.ENTRIES]); } else throw new Exception("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); diff --git a/spine-csharp/src/Skin.cs b/spine-csharp/src/Skin.cs index 973e49129..ef743a0c5 100644 --- a/spine-csharp/src/Skin.cs +++ b/spine-csharp/src/Skin.cs @@ -37,7 +37,7 @@ namespace Spine { /// Runtime skins in the Spine Runtimes Guide. /// public class Skin { - internal String name; + internal string name; private Dictionary attachments = new Dictionary(AttachmentKeyTupleComparer.Instance); @@ -49,11 +49,13 @@ namespace Spine { this.name = name; } + /// Adds an attachment to the skin for the specified slot index and name. public void AddAttachment (int slotIndex, string name, Attachment attachment) { if (attachment == null) throw new ArgumentNullException("attachment", "attachment cannot be null."); attachments[new AttachmentKeyTuple(slotIndex, name)] = attachment; } + /// Returns the attachment for the specified slot index and name, or null. /// May be null. public Attachment GetAttachment (int slotIndex, string name) { Attachment attachment; @@ -79,7 +81,7 @@ namespace Spine { if (entry.Key.slotIndex == slotIndex) attachments.Add(entry.Value); } - override public String ToString () { + override public string ToString () { return name; }