azerion / phaser-spine

A plugin for Phaser 2 that adds Spine support
MIT License
121 stars 57 forks source link

Bounding Box attachment types do not store vertices #25

Closed AshMobilePie closed 7 years ago

AshMobilePie commented 7 years ago

We noticed this when replacing our Spine plugin.

The vertices member of BoundingBoxAttachment is a Float32Array, which is a fixed-length data type. As such, when you push the vertices in during readAttachment(), none of the data actually gets stored.

As a temporary fix, we've hacked the readAttachment() method to look like this:

        case spine.AttachmentType.boundingbox:
            var attachment = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
            var vertices = map["vertices"];
            attachment.vertices = new spine.Float32Array(vertices.length);
            for (var i = 0, n = vertices.length; i < n; i++){
                attachment.vertices[i] = vertices[i] * scale;
            }
            return attachment;
AleBles commented 7 years ago

Sorry for not spotting this earlier, nice find!