diff --git a/CHANGELOG.md b/CHANGELOG.md index 335e2a4f1..555f083da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ * Added support for rotated regions in texture atlas loaded via StarlingAtlasAttachmentLoader. * Added support for vertex effects. See `RaptorExample.as` * Added 'getTexture()' method to 'StarlingTextureAtlasAttachmentLoader' + * Breaking change: if a skeleton requires two color tinting, you have to enable it via `SkeletonSprite.twoColorTint = true`. In this case the skeleton will use the `TwoColorMeshStyle`, which internally uses a different vertex layout and shader. This means that skeletons with two color tinting enabled will break batching and hence increase the number of draw calls in your app. ## C * **Breaking changes** diff --git a/spine-starling/spine-starling-example/.settings/org.eclipse.core.resources.prefs b/spine-starling/spine-starling-example/.settings/org.eclipse.core.resources.prefs index 33e6c92c2..adcfe1dd6 100644 --- a/spine-starling/spine-starling-example/.settings/org.eclipse.core.resources.prefs +++ b/spine-starling/spine-starling-example/.settings/org.eclipse.core.resources.prefs @@ -1,11 +1,4 @@ eclipse.preferences.version=1 encoding//src/spine/examples/TankExample.as=UTF-8 encoding//src/spine/examples/TwoColorExample.as=UTF-8 -encoding//src/spine/starling/SkeletonAnimation.as=UTF-8 -encoding//src/spine/starling/SkeletonMesh.as=UTF-8 -encoding//src/spine/starling/SkeletonSprite.as=UTF-8 -encoding//src/spine/starling/StarlingAtlasAttachmentLoader.as=UTF-8 -encoding//src/spine/starling/StarlingTextureLoader.as=UTF-8 -encoding//src/spine/starling/TwoColorEffect.as=UTF-8 -encoding//src/spine/starling/TwoColorMeshStyle.as=UTF-8 encoding/=UTF-8 diff --git a/spine-starling/spine-starling-example/lib/spine-starling.swc b/spine-starling/spine-starling-example/lib/spine-starling.swc index 38f36082b..f360d6595 100644 Binary files a/spine-starling/spine-starling-example/lib/spine-starling.swc and b/spine-starling/spine-starling-example/lib/spine-starling.swc differ diff --git a/spine-starling/spine-starling-example/src/spine/examples/CoinExample.as b/spine-starling/spine-starling-example/src/spine/examples/CoinExample.as index eb0ee2248..2c1978d55 100644 --- a/spine-starling/spine-starling-example/src/spine/examples/CoinExample.as +++ b/spine-starling/spine-starling-example/src/spine/examples/CoinExample.as @@ -72,6 +72,11 @@ package spine.examples { skeleton.state.timeScale = 0.5; skeleton.state.update(0.25); skeleton.state.apply(skeleton.skeleton); + + // enable two color tinting, which breaks batching between this skeleton + // and other Starling objects. + skeleton.twoColorTint = true; + skeleton.skeleton.updateWorldTransform(); addChild(skeleton); diff --git a/spine-starling/spine-starling/src/spine/starling/SkeletonSprite.as b/spine-starling/spine-starling/src/spine/starling/SkeletonSprite.as index 7c4c885c7..f1c4d1463 100644 --- a/spine-starling/spine-starling/src/spine/starling/SkeletonSprite.as +++ b/spine-starling/spine-starling/src/spine/starling/SkeletonSprite.as @@ -59,9 +59,9 @@ package spine.starling { static private var _tempMatrix : Matrix = new Matrix(); static private var _tempVertices : Vector. = new Vector.(8); static internal var blendModes : Vector. = new [BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN]; - private var _skeleton : Skeleton; - public var batchable : Boolean = true; + private var _skeleton : Skeleton; private var _smoothing : String = "bilinear"; + private var _twoColorTint : Boolean = false; private static var clipper: SkeletonClipping = new SkeletonClipping(); private static var QUAD_INDICES : Vector. = new [0, 1, 2, 2, 3, 0]; @@ -112,7 +112,7 @@ package spine.starling { region.rendererObject = mesh = new SkeletonMesh(Image(region.rendererObject).texture); if (region.rendererObject is AtlasRegion) region.rendererObject = mesh = new SkeletonMesh(Image(AtlasRegion(region.rendererObject).rendererObject).texture); - mesh.setStyle(new TwoColorMeshStyle()); + if (_twoColorTint) mesh.setStyle(new TwoColorMeshStyle()); indexData = mesh.getIndexData(); for (ii = 0; ii < indices.length; ii++) indexData.setIndex(ii, indices[ii]); @@ -136,7 +136,7 @@ package spine.starling { meshAttachment.rendererObject = mesh = new SkeletonMesh(Image(meshAttachment.rendererObject).texture); if (meshAttachment.rendererObject is AtlasRegion) meshAttachment.rendererObject = mesh = new SkeletonMesh(Image(AtlasRegion(meshAttachment.rendererObject).rendererObject).texture); - mesh.setStyle(new TwoColorMeshStyle()); + if (_twoColorTint) mesh.setStyle(new TwoColorMeshStyle()); indexData = mesh.getIndexData(); indicesLength = meshAttachment.triangles.length; @@ -198,13 +198,13 @@ package spine.starling { tempVertex.dark.setFromColor(tempDark); vertexEffect.transform(tempVertex); vertexData.colorize("color", Color.rgb(tempVertex.light.r * 255, tempVertex.light.g * 255, tempVertex.light.b * 255), tempVertex.light.a, ii, 1); - vertexData.colorize("color2", Color.rgb(tempVertex.dark.r * 255, tempVertex.dark.g * 255, tempVertex.dark.b * 255), a, ii, 1); + if (_twoColorTint) vertexData.colorize("color2", Color.rgb(tempVertex.dark.r * 255, tempVertex.dark.g * 255, tempVertex.dark.b * 255), a, ii, 1); mesh.setVertexPosition(ii, tempVertex.x, tempVertex.y); mesh.setTexCoords(ii, tempVertex.u, tempVertex.v); } } else { vertexData.colorize("color", rgb, a); - vertexData.colorize("color2", dark); + if (_twoColorTint) vertexData.colorize("color2", dark); for (ii = 0, iii = 0; ii < verticesCount; ii++, iii += 2) { mesh.setVertexPosition(ii, worldVertices[iii], worldVertices[iii + 1]); mesh.setTexCoords(ii, uvs[iii], uvs[iii + 1]); @@ -303,5 +303,13 @@ package spine.starling { public function set smoothing(smoothing : String) : void { _smoothing = smoothing; } + + public function get twoColorTint() : Boolean { + return _twoColorTint; + } + + public function set twoColorTint(tint : Boolean) : void { + _twoColorTint = tint; + } } } \ No newline at end of file