From cd23c5f84c905f900b9783bcdb88fc7e141c42f6 Mon Sep 17 00:00:00 2001 From: badlogic Date: Mon, 13 Mar 2017 17:12:00 +0100 Subject: [PATCH] [love] Fixed two color tinting. --- spine-love/README.md | 6 +++++- spine-love/spine-love/spine.lua | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/spine-love/README.md b/spine-love/README.md index 45ddea4df..0eff5b7f9 100644 --- a/spine-love/README.md +++ b/spine-love/README.md @@ -10,7 +10,7 @@ The Spine Runtimes are developed with the intent to be used with data exported f ## Spine version -spine-love works with data exported from Spine 3.5.xx. +spine-love works with data exported from Spine 3.6.x. spine-love supports all Spine features except for blending modes other than normal. @@ -24,6 +24,10 @@ spine-love does not yet support loading the binary format. Alternatively, the `spine-lua` and `spine-love/spine-love` directories can be copied into your project. Note that the require statements use `spine-lua.Xxx`, so the spine-lua files must be in a `spine-lua` directory in your project. +## Notes + + * Two enable two color tinting, pass `true` to `SkeletonRenderer.new()`. + ## Examples [Simple Example](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-love/main.lua) diff --git a/spine-love/spine-love/spine.lua b/spine-love/spine-love/spine.lua index b35cfe423..4ee4c9181 100644 --- a/spine-love/spine-love/spine.lua +++ b/spine-love/spine-love/spine.lua @@ -268,6 +268,7 @@ end local worldVertices = spine.utils.newNumberArray(10000 * 12) local tmpColor = spine.Color.newWith(0, 0, 0, 0) +local tmpColor2 = spine.Color.newWith(0, 0, 0, 0) function SkeletonRenderer:draw (skeleton) local batcher = self.batcher @@ -323,8 +324,6 @@ function SkeletonRenderer:draw (skeleton) love.graphics.setBlendMode(lastLoveBlendMode) end -local tmpColor2 = spine.Color.new() - function SkeletonRenderer:computeRegionVertices(slot, region, pma, color) local skeleton = slot.bone.skeleton local skeletonColor = skeleton.color @@ -338,8 +337,9 @@ function SkeletonRenderer:computeRegionVertices(slot, region, pma, color) skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha) - local dark = tmpColor - if slot.darkColor then dark = slot.darkColor end + local dark = tmpColor2 + if slot.darkColor then dark = slot.darkColor + else dark:set(0, 0, 0, 0) end local vertices = worldVertices if not self.useTwoColorTint then @@ -443,8 +443,9 @@ function SkeletonRenderer:computeMeshVertices(slot, mesh, pma, color) local numVertices = mesh.worldVerticesLength / 2 local vertices = worldVertices - local dark = tmpColor - if slot.darkColor then dark = slot.darkColor end + local dark = tmpColor2 + if slot.darkColor then dark = slot.darkColor + else dark:set(0, 0, 0, 0) end if not self.useTwoColorTint then mesh:computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 8)