From 3a9623cdd7f1f7a376442d36ee760de1f9ff1b08 Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2013 11:19:08 +0300 Subject: [PATCH 1/6] add support for loading from relative directories to make the example load out of the box --- spine-corona/spine-corona/spine.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spine-corona/spine-corona/spine.lua b/spine-corona/spine-corona/spine.lua index 36c9b684c..e4cca7b8c 100644 --- a/spine-corona/spine-corona/spine.lua +++ b/spine-corona/spine-corona/spine.lua @@ -25,6 +25,9 @@ spine = {} +local path = system.pathForFile("../") +package.path = package.path .. ";".. path .. "/?.lua" + spine.utils = require "spine-lua.utils" spine.SkeletonJson = require "spine-lua.SkeletonJson" spine.SkeletonData = require "spine-lua.SkeletonData" From 32c7dc8cb0acf7ede329c9382fb3ec705a89c399 Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2013 11:50:26 +0300 Subject: [PATCH 2/6] Revert "add support for loading from relative directories to make the example load out of the box" This reverts commit 3a9623cdd7f1f7a376442d36ee760de1f9ff1b08. --- spine-corona/spine-corona/spine.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/spine-corona/spine-corona/spine.lua b/spine-corona/spine-corona/spine.lua index e4cca7b8c..36c9b684c 100644 --- a/spine-corona/spine-corona/spine.lua +++ b/spine-corona/spine-corona/spine.lua @@ -25,9 +25,6 @@ spine = {} -local path = system.pathForFile("../") -package.path = package.path .. ";".. path .. "/?.lua" - spine.utils = require "spine-lua.utils" spine.SkeletonJson = require "spine-lua.SkeletonJson" spine.SkeletonData = require "spine-lua.SkeletonData" From b5da5daa3866756b34794674795f77fbab2f946f Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2013 12:05:31 +0300 Subject: [PATCH 3/6] add relative path to package.path to make running the example work straight out of the box on simulator --- spine-corona/spine-corona/spine.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spine-corona/spine-corona/spine.lua b/spine-corona/spine-corona/spine.lua index 36c9b684c..c45e75ce2 100644 --- a/spine-corona/spine-corona/spine.lua +++ b/spine-corona/spine-corona/spine.lua @@ -25,6 +25,10 @@ spine = {} +if (system.getInfo("environment") == "simulator") then + package.path = package.path .. ";".. system.pathForFile("../") .. "/?.lua" +end + spine.utils = require "spine-lua.utils" spine.SkeletonJson = require "spine-lua.SkeletonJson" spine.SkeletonData = require "spine-lua.SkeletonData" From 460451a6a28bd7bb4561beeaee3386f0b8e4472b Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2013 12:18:18 +0300 Subject: [PATCH 4/6] 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 From f3d1467972b1abf7b41fad7095e0533658427f9c Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2013 12:24:36 +0300 Subject: [PATCH 5/6] comment out the warning --- spine-corona/spine-corona/spine.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spine-corona/spine-corona/spine.lua b/spine-corona/spine-corona/spine.lua index 426d60ef1..754112e0d 100644 --- a/spine-corona/spine-corona/spine.lua +++ b/spine-corona/spine-corona/spine.lua @@ -119,7 +119,7 @@ function spine.Skeleton.new (skeletonData, group) 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 + --if (rot ~= 0 and (slot.bone.worldScaleX ~= 1 or slot.bone.worldScaleY ~= 1)) 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 From 116ad3ce533607769ee7a68ddf27bc664863155b Mon Sep 17 00:00:00 2001 From: Matias Date: Wed, 29 May 2013 12:29:49 +0300 Subject: [PATCH 6/6] fix indentation --- spine-corona/spine-corona/spine.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spine-corona/spine-corona/spine.lua b/spine-corona/spine-corona/spine.lua index 754112e0d..bc565e2e8 100644 --- a/spine-corona/spine-corona/spine.lua +++ b/spine-corona/spine-corona/spine.lua @@ -113,16 +113,16 @@ function spine.Skeleton.new (skeletonData, group) image.y = -(slot.bone.worldY + attachment.x * slot.bone.m10 + attachment.y * slot.bone.m11) image.rotation = -(slot.bone.worldRotation + attachment.rotation) - -- 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 and (slot.bone.worldScaleX ~= 1 or slot.bone.worldScaleY ~= 1)) 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 + -- 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 and (slot.bone.worldScaleX ~= 1 or slot.bone.worldScaleY ~= 1)) 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