From e4b392d4c8e09bd2ebcef62532c53632a5854d6f Mon Sep 17 00:00:00 2001 From: Jacky Date: Wed, 15 Jul 2015 16:27:29 +0800 Subject: [PATCH] fix polygon sprite setColor, setOpacity, setTexture, setTextureRect. --- cocos/2d/CCSprite.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index faa5b61e79..b02872baf5 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -265,7 +265,6 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) setTexture(texture); setTextureRect(rect, rotated, rect.size); - _polyInfo.setQuad(&_quad); // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" setBatchNode(nullptr); @@ -424,6 +423,8 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme _quad.tl.vertices.set(x1, y2, 0.0f); _quad.tr.vertices.set(x2, y2, 0.0f); } + + _polyInfo.setQuad(&_quad); } void Sprite::debugDraw(bool on) @@ -942,10 +943,9 @@ void Sprite::updateColor(void) color4.b *= _displayedOpacity/255.0f; } - _quad.bl.colors = color4; - _quad.br.colors = color4; - _quad.tl.colors = color4; - _quad.tr.colors = color4; + for (ssize_t i = 0; i < _polyInfo.triangles.vertCount; i++) { + _polyInfo.triangles.verts[i].colors = color4; + } // renders using batch node if (_batchNode)