Răsfoiți Sursa

Merge pull request #228 from moberghammer/master

AttachmentLoader fixes
Nathan Sweet 11 ani în urmă
părinte
comite
5c5505dfcb
1 a modificat fișierele cu 5 adăugiri și 4 ștergeri
  1. 5 4
      spine-js/spine.js

+ 5 - 4
spine-js/spine.js

@@ -123,7 +123,7 @@ spine.Slot.prototype = {
 	r: 1, g: 1, b: 1, a: 1,
 	_attachmentTime: 0,
 	attachment: null,
-	attachmentVertices: null,
+	attachmentVertices: [],
 	setAttachment: function (attachment) {
 		this.attachment = attachment;
 		this._attachmentTime = this.skeleton.time;
@@ -1461,7 +1461,7 @@ spine.SkeletonJson.prototype = {
 		
 		var scale = this.scale;
 		if (type == spine.AttachmentType.region) {
-			var region = attachmentLoader.newRegionAttachment(skin, name, path);
+			var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
 			if (!region) return null;
 			region.path = path;
 			region.x = (map["x"] || 0) * this.scale;
@@ -1483,7 +1483,7 @@ spine.SkeletonJson.prototype = {
 			region.updateOffset();
 			return region;
 		} else if (type == spine.AttachmentType.mesh) {
-			var mesh = attachmentLoader.newMeshAttachment(skin, name, path);
+			var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
 			if (!mesh) return null;
 			mesh.path = path; 
 			mesh.vertices = this.getFloatArray(map, "vertices", scale);
@@ -1505,7 +1505,7 @@ spine.SkeletonJson.prototype = {
 			mesh.height = (map["height"] || 0) * scale;
 			return mesh;
 		} else if (type == spine.AttachmentType.skinnedmesh) {
-			var mesh = attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
+			var mesh = this.attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
 			if (!mesh) return null;
 			mesh.path = path;
 
@@ -1544,6 +1544,7 @@ spine.SkeletonJson.prototype = {
 			mesh.height = (map["height"] || 0) * scale;
 			return mesh;
 		} else if (type == spine.AttachmentType.boundingbox) {
+            var attachment = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
 			var vertices = map["vertices"];
 			for (var i = 0, n = vertices.length; i < n; i++)
 				attachment.vertices.push(vertices[i] * this.scale);