diff --git a/spine-as3/spine-as3/src/spine/Skeleton.as b/spine-as3/spine-as3/src/spine/Skeleton.as index d554706ea..83770ac7c 100644 --- a/spine-as3/spine-as3/src/spine/Skeleton.as +++ b/spine-as3/spine-as3/src/spine/Skeleton.as @@ -177,18 +177,21 @@ public class Skeleton { * each slot's setup mode attachment is attached from the new skin. * @param newSkin May be null. */ public function set skin (newSkin:Skin) : void { - if (!skin) { - var i:int = 0; - for each (var slot:Slot in _slots) { - var name:String = slot.data.attachmentName; - if (name) { - var attachment:Attachment = newSkin.getAttachment(i, name); - if (attachment) slot.attachment = attachment; + if (newSkin) { + if (skin) + newSkin.attachAll(this, skin); + else { + var i:int = 0; + for each (var slot:Slot in _slots) { + var name:String = slot.data.attachmentName; + if (name) { + var attachment:Attachment = newSkin.getAttachment(i, name); + if (attachment) slot.attachment = attachment; + } + i++; } - i++; } - } else if (newSkin) - newSkin.attachAll(this, skin); + } _skin = newSkin; } diff --git a/spine-as3/spine-as3/src/spine/SkeletonJson.as b/spine-as3/spine-as3/src/spine/SkeletonJson.as index a3e8c04c3..ba529f796 100644 --- a/spine-as3/spine-as3/src/spine/SkeletonJson.as +++ b/spine-as3/spine-as3/src/spine/SkeletonJson.as @@ -411,7 +411,7 @@ public class SkeletonJson { } if (attachment is MeshAttachment) { var meshVertices:Vector. = (attachment as MeshAttachment).vertices; - for (i = 0, n = vertices.length; i < n; i++) + for (i = 0; i < vertexCount; i++) vertices[i] += meshVertices[i]; } } diff --git a/spine-c/src/spine/Skeleton.c b/spine-c/src/spine/Skeleton.c index 13c948f6f..be7fc423d 100644 --- a/spine-c/src/spine/Skeleton.c +++ b/spine-c/src/spine/Skeleton.c @@ -163,17 +163,21 @@ int spSkeleton_setSkinByName (spSkeleton* self, const char* skinName) { } void spSkeleton_setSkin (spSkeleton* self, spSkin* newSkin) { - if (!self->skin) { - int i; - for (i = 0; i < self->slotCount; ++i) { - spSlot* slot = self->slots[i]; - if (slot->data->attachmentName) { - spAttachment* attachment = spSkin_getAttachment(newSkin, i, slot->data->attachmentName); - if (attachment) spSlot_setAttachment(slot, attachment); + if (newSkin) { + if (self->skin) + spSkin_attachAll(newSkin, self, self->skin); + else { + /* No previous skin, attach setup pose attachments. */ + int i; + for (i = 0; i < self->slotCount; ++i) { + spSlot* slot = self->slots[i]; + if (slot->data->attachmentName) { + spAttachment* attachment = spSkin_getAttachment(newSkin, i, slot->data->attachmentName); + if (attachment) spSlot_setAttachment(slot, attachment); + } } } - } else if (newSkin) /**/ - spSkin_attachAll(newSkin, self, self->skin); + } CONST_CAST(spSkin*, self->skin) = newSkin; } diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs index f8e54bedd..07cb95413 100644 --- a/spine-csharp/src/Skeleton.cs +++ b/spine-csharp/src/Skeleton.cs @@ -165,18 +165,21 @@ namespace Spine { /// setup mode attachment is attached from the new skin. /// May be null. public void SetSkin (Skin newSkin) { - if (skin == null) { - List slots = this.slots; - for (int i = 0, n = slots.Count; i < n; i++) { - Slot slot = slots[i]; - String name = slot.data.attachmentName; - if (name != null) { - Attachment attachment = newSkin.GetAttachment(i, name); - if (attachment != null) slot.Attachment = attachment; + if (newSkin != null) { + if (skin != null) + newSkin.AttachAll(this, skin); + else { + List slots = this.slots; + for (int i = 0, n = slots.Count; i < n; i++) { + Slot slot = slots[i]; + String name = slot.data.attachmentName; + if (name != null) { + Attachment attachment = newSkin.GetAttachment(i, name); + if (attachment != null) slot.Attachment = attachment; + } } } - } else if (newSkin != null) // - newSkin.AttachAll(this, skin); + } skin = newSkin; } diff --git a/spine-csharp/src/SkeletonJson.cs b/spine-csharp/src/SkeletonJson.cs index e7b2a0db5..11c951419 100644 --- a/spine-csharp/src/SkeletonJson.cs +++ b/spine-csharp/src/SkeletonJson.cs @@ -483,7 +483,7 @@ namespace Spine { } if (attachment is MeshAttachment) { float[] meshVertices = ((MeshAttachment)attachment).vertices; - for (int i = 0, n = vertices.Length; i < n; i++) + for (int i = 0; i < vertexCount; i++) vertices[i] += meshVertices[i]; } } diff --git a/spine-js/spine.js b/spine-js/spine.js index 445ba0aa6..27548d56a 100644 --- a/spine-js/spine.js +++ b/spine-js/spine.js @@ -828,18 +828,21 @@ spine.Skeleton.prototype = { * each slot's setup mode attachment is attached from the new skin. * @param newSkin May be null. */ setSkin: function (newSkin) { - if (!this.skin) { - var slots = this.slots; - for (var i = 0, n = slots.length; i < n; i++) { - var slot = slots[i]; - var name = slot.data.attachmentName; - if (name) { - var attachment = newSkin.getAttachment(i, name); - if (attachment) slot.setAttachment(attachment); + if (newSkin) { + if (this.skin) + newSkin._attachAll(this, this.skin); + else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name = slot.data.attachmentName; + if (name) { + var attachment = newSkin.getAttachment(i, name); + if (attachment) slot.setAttachment(attachment); + } } } - } else if (newSkin) - newSkin._attachAll(this, this.skin); + } this.skin = newSkin; }, /** @return May be null. */ @@ -915,6 +918,8 @@ spine.RegionAttachment.prototype = { rotation: 0, scaleX: 1, scaleY: 1, width: 0, height: 0, + r: 1, g: 1, b: 1, a: 1, + path: null, rendererObject: null, regionOffsetX: 0, regionOffsetY: 0, regionWidth: 0, regionHeight: 0, @@ -1004,7 +1009,7 @@ spine.MeshAttachment.prototype = { regionOriginalWidth: 0, regionOriginalHeight: 0, edges: null, width: 0, height: 0, - updateUVs: function (u, v, u2, v2, rotate) { + updateUVs: function () { var width = regionU2 - regionU, height = regionV2 - regionV; var n = regionUVs.length; if (!uvs || uvs.length != n) { diff --git a/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java b/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java index cc432f972..91d7070c6 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java @@ -209,18 +209,21 @@ public class Skeleton { * each slot's setup mode attachment is attached from the new skin. * @param newSkin May be null. */ public void setSkin (Skin newSkin) { - if (skin == null) { - Array slots = this.slots; - for (int i = 0, n = slots.size; i < n; i++) { - Slot slot = slots.get(i); - String name = slot.data.attachmentName; - if (name != null) { - Attachment attachment = newSkin.getAttachment(i, name); - if (attachment != null) slot.setAttachment(attachment); + if (newSkin != null) { + if (skin != null) + newSkin.attachAll(this, skin); + else { + Array slots = this.slots; + for (int i = 0, n = slots.size; i < n; i++) { + Slot slot = slots.get(i); + String name = slot.data.attachmentName; + if (name != null) { + Attachment attachment = newSkin.getAttachment(i, name); + if (attachment != null) slot.setAttachment(attachment); + } } } - } else if (newSkin != null) // - newSkin.attachAll(this, skin); + } skin = newSkin; } diff --git a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java index ca8864c92..0c50cc950 100644 --- a/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java +++ b/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java @@ -390,7 +390,7 @@ public class SkeletonJson { } if (attachment instanceof MeshAttachment) { float[] meshVertices = ((MeshAttachment)attachment).getVertices(); - for (int i = 0, n = vertices.length; i < n; i++) + for (int i = 0; i < vertexCount; i++) vertices[i] += meshVertices[i]; } }