浏览代码

[love] Fixed two color tinting.

badlogic 8 年之前
父节点
当前提交
cd23c5f84c
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 5 1
      spine-love/README.md
  2. 7 6
      spine-love/spine-love/spine.lua

+ 5 - 1
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)

+ 7 - 6
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)