Merge pull request #228 from moberghammer/master

AttachmentLoader fixes
This commit is contained in:
Nathan Sweet 2014-05-23 11:37:00 +02:00
commit 5c5505dfcb

View File

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