Skip to content

Commit

Permalink
Merge pull request cocos2d#12863 from fusijie/fix_polygonsprite_setColor
Browse files Browse the repository at this point in the history
fix polygon sprite setColor, setOpacity, setTexture, setTextureRect.
  • Loading branch information
zilongshanren committed Jul 16, 2015
2 parents 63add82 + e4b392d commit a72ea73
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cocos/2d/CCSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -943,10 +944,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)
Expand Down

0 comments on commit a72ea73

Please sign in to comment.