NathanSweet před 11 roky
rodič
revize
cf41610f8a

+ 13 - 10
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;
 	}
 

+ 1 - 1
spine-as3/spine-as3/src/spine/SkeletonJson.as

@@ -411,7 +411,7 @@ public class SkeletonJson {
 							}
 							if (attachment is MeshAttachment) {
 								var meshVertices:Vector.<Number> = (attachment as MeshAttachment).vertices;
-								for (i = 0, n = vertices.length; i < n; i++)
+								for (i = 0; i < vertexCount; i++)
 									vertices[i] += meshVertices[i];
 							}
 						}

+ 13 - 9
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;
 }
 

+ 13 - 10
spine-csharp/src/Skeleton.cs

@@ -165,18 +165,21 @@ namespace Spine {
 		/// setup mode attachment is attached from the new skin.</summary>
 		/// <param name="newSkin">May be null.</param>
 		public void SetSkin (Skin newSkin) {
-			if (skin == null) {
-				List<Slot> 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<Slot> 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;
 		}
 

+ 1 - 1
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];
 									}
 								}

+ 16 - 11
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) {

+ 13 - 10
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<Slot> 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<Slot> 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;
 	}
 

+ 1 - 1
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];
 							}
 						}