From 460451a6a28bd7bb4561beeaee3386f0b8e4472b Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2013 12:18:18 +0300 Subject: [PATCH] fix scaling when attachment is rotated 90 degrees from the bone --- spine-corona/spine-corona/spine.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/spine-corona/spine-corona/spine.lua b/spine-corona/spine-corona/spine.lua index c45e75ce2..426d60ef1 100644 --- a/spine-corona/spine-corona/spine.lua +++ b/spine-corona/spine-corona/spine.lua @@ -112,8 +112,18 @@ function spine.Skeleton.new (skeletonData, group) image.x = slot.bone.worldX + attachment.x * slot.bone.m00 + attachment.y * slot.bone.m01 image.y = -(slot.bone.worldY + attachment.x * slot.bone.m10 + attachment.y * slot.bone.m11) image.rotation = -(slot.bone.worldRotation + attachment.rotation) - image.xScale = slot.bone.worldScaleX + attachment.scaleX - 1 - image.yScale = slot.bone.worldScaleY + attachment.scaleY - 1 + + -- fix scaling when attachment is rotated 90 degrees + local rot = math.abs(attachment.rotation) % 180 + if (rot == 90) then + image.xScale = slot.bone.worldScaleY * attachment.scaleX + image.yScale = slot.bone.worldScaleX * attachment.scaleY + else + if (rot ~= 0) then print("WARNING: Scaling bones with attachments not rotated to the cardinal angles will not work as expected in Corona!") end + image.xScale = slot.bone.worldScaleX * attachment.scaleX + image.yScale = slot.bone.worldScaleY * attachment.scaleY + end + if self.flipX then image.xScale = -image.xScale image.rotation = -image.rotation