[cocos2dx] Fixed tinting and cascaded colors. Closes #902, closes #901

This commit is contained in:
badlogic 2017-05-17 11:03:34 +02:00
parent a43bdc4361
commit 1af2089157
2 changed files with 11 additions and 10 deletions

View File

@ -50,6 +50,7 @@
* Updated example to use Cocos2d-x 3.14.1. * Updated example to use Cocos2d-x 3.14.1.
* Added mesh debug rendering. Enable/Disable via `SkeletonRenderer::setDebugMeshesEnabled()`. * Added mesh debug rendering. Enable/Disable via `SkeletonRenderer::setDebugMeshesEnabled()`.
* Added support for clipping. * Added support for clipping.
* SkeletonRenderer now combines the displayed color of the Node (cascaded from all parents) with the skeleton color for tinting.
### Cocos2d-Objc ### Cocos2d-Objc
* Fixed renderer to work with 3.6 changes * Fixed renderer to work with 3.6 changes

View File

@ -184,11 +184,11 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
SkeletonTwoColorBatch* twoColorBatch = SkeletonTwoColorBatch::getInstance(); SkeletonTwoColorBatch* twoColorBatch = SkeletonTwoColorBatch::getInstance();
bool isTwoColorTint = this->isTwoColorTint(); bool isTwoColorTint = this->isTwoColorTint();
Color3B nodeColor = getColor(); Color4F nodeColor;
_skeleton->color.r = nodeColor.r / (float)255; nodeColor.r = getDisplayedColor().r / (float)255;
_skeleton->color.g = nodeColor.g / (float)255; nodeColor.g = getDisplayedColor().g / (float)255;
_skeleton->color.b = nodeColor.b / (float)255; nodeColor.b = getDisplayedColor().b / (float)255;
_skeleton->color.a = getDisplayedOpacity() / (float)255; nodeColor.a = getDisplayedOpacity() / (float)255;
Color4F color; Color4F color;
Color4F darkColor; Color4F darkColor;
@ -278,11 +278,11 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t
darkColor.b = 0; darkColor.b = 0;
} }
color.a *= _skeleton->color.a * slot->color.a * 255; color.a *= nodeColor.a * _skeleton->color.a * slot->color.a * 255;
float multiplier = _premultipliedAlpha ? color.a : 255; float multiplier = _premultipliedAlpha ? color.a : 255;
color.r *= _skeleton->color.r * slot->color.r * multiplier; color.r *= nodeColor.r * _skeleton->color.r * slot->color.r * multiplier;
color.g *= _skeleton->color.g * slot->color.g * multiplier; color.g *= nodeColor.g * _skeleton->color.g * slot->color.g * multiplier;
color.b *= _skeleton->color.b * slot->color.b * multiplier; color.b *= nodeColor.b * _skeleton->color.b * slot->color.b * multiplier;
BlendFunc blendFunc; BlendFunc blendFunc;
switch (slot->data->blendMode) { switch (slot->data->blendMode) {