diff --git a/spine-as3/spine-as3/lib/spine-as3.swc b/spine-as3/spine-as3/lib/spine-as3.swc index f72fc9cb7..a804da54e 100644 Binary files a/spine-as3/spine-as3/lib/spine-as3.swc and b/spine-as3/spine-as3/lib/spine-as3.swc differ diff --git a/spine-as3/spine-as3/src/spine/BinaryInput.as b/spine-as3/spine-as3/src/spine/BinaryInput.as index 702c51814..256408877 100644 --- a/spine-as3/spine-as3/src/spine/BinaryInput.as +++ b/spine-as3/spine-as3/src/spine/BinaryInput.as @@ -29,26 +29,26 @@ package spine { import flash.utils.ByteArray; - - class BinaryInput { - private var bytes : ByteArray; + + public class BinaryInput { + private var bytes : ByteArray; public var strings : Vector. = new Vector.(); - + public function BinaryInput(bytes: ByteArray) { - this.bytes = bytes; + this.bytes = bytes; } public function readByte() : int { - return bytes.readByte(); + return bytes.readByte(); } - + public function readShort() : int { return bytes.readShort(); } - + public function readInt32(): int { return bytes.readInt(); } - + public function readInt(optimizePositive: Boolean) : int { var b : int = readByte(); var result : int = b & 0x7F; @@ -70,12 +70,12 @@ package spine { } return optimizePositive ? result : ((result >>> 1) ^ -(result & 1)); } - + public function readStringRef (): String { var index : int = readInt(true); return index == 0 ? null : strings[index - 1]; } - + public function readString () : String { var byteCount : int = readInt(true); switch (byteCount) { @@ -85,7 +85,7 @@ package spine { return ""; } byteCount--; - var chars : String = ""; + var chars : String = ""; for (var i : int = 0; i < byteCount;) { var b : int = readByte(); switch (b >> 4) { @@ -105,11 +105,11 @@ package spine { } return chars; } - + public function readFloat (): Number { - return bytes.readFloat(); + return bytes.readFloat(); } - + public function readBoolean (): Boolean { return this.readByte() != 0; } diff --git a/spine-as3/spine-as3/src/spine/attachments/RegionAttachment.as b/spine-as3/spine-as3/src/spine/attachments/RegionAttachment.as index 909adad59..0140753cf 100644 --- a/spine-as3/spine-as3/src/spine/attachments/RegionAttachment.as +++ b/spine-as3/spine-as3/src/spine/attachments/RegionAttachment.as @@ -30,6 +30,7 @@ package spine.attachments { import spine.Color; import spine.Bone; + import flash.trace.Trace; public dynamic class RegionAttachment extends Attachment { public const BLX : int = 0; @@ -72,25 +73,26 @@ package spine.attachments { var localY : Number = -height * 0.5 * scaleY + regionOffsetY * regionScaleY; var localX2 : Number = localX + regionWidth * regionScaleX; var localY2 : Number = localY + regionHeight * regionScaleY; - + var radians : Number = rotation * Math.PI / 180; - var ulDist : Number = Math.sqrt(localX * localX + localY * localY); - var ulAngle : Number = Math.atan2(localY, localX); - var urDist : Number = Math.sqrt(localX2 * localX2 + localY * localY); - var urAngle : Number = Math.atan2(localY, localX2); - var blDist : Number = Math.sqrt(localX * localX + localY2 * localY2); - var blAngle : Number = Math.atan2(localY2, localX); - var brDist : Number = Math.sqrt(localX2 * localX2 + localY2 * localY2); - var brAngle : Number = Math.atan2(localY2, localX2); - - offset[BLX] = Math.cos(radians - blAngle) * blDist + x; - offset[BLY] = Math.sin(radians - blAngle) * blDist + y; - offset[ULX] = Math.cos(radians - ulAngle) * ulDist + x; - offset[ULY] = Math.sin(radians - ulAngle) * ulDist + y; - offset[URX] = Math.cos(radians - urAngle) * urDist + x; - offset[URY] = Math.sin(radians - urAngle) * urDist + y; - offset[BRX] = Math.cos(radians - brAngle) * brDist + x; - offset[BRY] = Math.sin(radians - brAngle) * brDist + y; + var cos:Number = Math.cos(radians); + var sin:Number = Math.sin(radians); + var localXCos:Number = localX * cos + x; + var localXSin:Number = localX * sin; + var localYCos:Number = localY * cos + y; + var localYSin:Number = localY * sin; + var localX2Cos:Number = localX2 * cos + x; + var localX2Sin:Number = localX2 * sin; + var localY2Cos:Number = localY2 * cos + y; + var localY2Sin:Number = localY2 * sin; + offset[BLX] = localXCos - localYSin; + offset[BLY] = localYCos + localXSin; + offset[ULX] = localXCos - localY2Sin; + offset[ULY] = localY2Cos + localXSin; + offset[URX] = localX2Cos - localY2Sin; + offset[URY] = localY2Cos + localX2Sin; + offset[BRX] = localX2Cos - localYSin; + offset[BRY] = localYCos + localX2Sin; } public function setUVs(u : Number, v : Number, u2 : Number, v2 : Number, rotate : Boolean) : void { @@ -127,33 +129,33 @@ package spine.attachments { worldVertices[offset] = offsetX * a + offsetY * b + x; // br worldVertices[offset + 1] = offsetX * c + offsetY * d + y; offset += stride; - + offsetX = vertexOffset[BLX]; offsetY = vertexOffset[BLY]; worldVertices[offset] = offsetX * a + offsetY * b + x; // bl worldVertices[offset + 1] = offsetX * c + offsetY * d + y; offset += stride; - + offsetX = vertexOffset[ULX]; offsetY = vertexOffset[ULY]; worldVertices[offset] = offsetX * a + offsetY * b + x; // ul worldVertices[offset + 1] = offsetX * c + offsetY * d + y; offset += stride; - + offsetX = vertexOffset[URX]; offsetY = vertexOffset[URY]; worldVertices[offset] = offsetX * a + offsetY * b + x; // ur worldVertices[offset + 1] = offsetX * c + offsetY * d + y; } - + override public function copy (): Attachment { - var copy : RegionAttachment = new RegionAttachment(name); + var copy : RegionAttachment = new RegionAttachment(name); copy.regionWidth = regionWidth; copy.regionHeight = regionHeight; copy.regionOffsetX = regionOffsetX; copy.regionOffsetY = regionOffsetY; copy.regionOriginalWidth = regionOriginalWidth; - copy.regionOriginalHeight = regionOriginalHeight; + copy.regionOriginalHeight = regionOriginalHeight; copy.rendererObject = rendererObject; copy.path = path; copy.x = x; @@ -164,7 +166,7 @@ package spine.attachments { copy.width = width; copy.height = height; copy.uvs = uvs.concat(); - copy.offset = offset.concat(); + copy.offset = offset.concat(); copy.color.setFromColor(color); return copy; } diff --git a/spine-starling/spine-starling/lib/spine-starling.swc b/spine-starling/spine-starling/lib/spine-starling.swc index 0e79e9150..d1580d567 100644 Binary files a/spine-starling/spine-starling/lib/spine-starling.swc and b/spine-starling/spine-starling/lib/spine-starling.swc differ