[love] Fixed two color tinting.

This commit is contained in:
badlogic 2017-03-13 17:12:00 +01:00
parent 8f923971ce
commit cd23c5f84c
2 changed files with 12 additions and 7 deletions

View File

@ -10,7 +10,7 @@ The Spine Runtimes are developed with the intent to be used with data exported f
## Spine version ## 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. 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. 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 ## Examples
[Simple Example](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-love/main.lua) [Simple Example](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-love/main.lua)

View File

@ -268,6 +268,7 @@ end
local worldVertices = spine.utils.newNumberArray(10000 * 12) local worldVertices = spine.utils.newNumberArray(10000 * 12)
local tmpColor = spine.Color.newWith(0, 0, 0, 0) local tmpColor = spine.Color.newWith(0, 0, 0, 0)
local tmpColor2 = spine.Color.newWith(0, 0, 0, 0)
function SkeletonRenderer:draw (skeleton) function SkeletonRenderer:draw (skeleton)
local batcher = self.batcher local batcher = self.batcher
@ -323,8 +324,6 @@ function SkeletonRenderer:draw (skeleton)
love.graphics.setBlendMode(lastLoveBlendMode) love.graphics.setBlendMode(lastLoveBlendMode)
end end
local tmpColor2 = spine.Color.new()
function SkeletonRenderer:computeRegionVertices(slot, region, pma, color) function SkeletonRenderer:computeRegionVertices(slot, region, pma, color)
local skeleton = slot.bone.skeleton local skeleton = slot.bone.skeleton
local skeletonColor = skeleton.color local skeletonColor = skeleton.color
@ -338,8 +337,9 @@ function SkeletonRenderer:computeRegionVertices(slot, region, pma, color)
skeletonColor.b * slotColor.b * regionColor.b * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier,
alpha) alpha)
local dark = tmpColor local dark = tmpColor2
if slot.darkColor then dark = slot.darkColor end if slot.darkColor then dark = slot.darkColor
else dark:set(0, 0, 0, 0) end
local vertices = worldVertices local vertices = worldVertices
if not self.useTwoColorTint then if not self.useTwoColorTint then
@ -443,8 +443,9 @@ function SkeletonRenderer:computeMeshVertices(slot, mesh, pma, color)
local numVertices = mesh.worldVerticesLength / 2 local numVertices = mesh.worldVerticesLength / 2
local vertices = worldVertices local vertices = worldVertices
local dark = tmpColor local dark = tmpColor2
if slot.darkColor then dark = slot.darkColor end if slot.darkColor then dark = slot.darkColor
else dark:set(0, 0, 0, 0) end
if not self.useTwoColorTint then if not self.useTwoColorTint then
mesh:computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 8) mesh:computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 8)