Fix polygon sprite bug of resetting flip and color information in setSpriteFrame. (#18085)

This commit is contained in:
Felippe Durán 2017-07-19 00:08:12 -03:00 committed by minggo
parent cdac595a68
commit 681e9aa752
2 changed files with 46 additions and 34 deletions

View File

@ -1433,7 +1433,30 @@ void Sprite::setFlippedX(bool flippedX)
if (_flippedX != flippedX)
{
_flippedX = flippedX;
flipX();
}
}
bool Sprite::isFlippedX(void) const
{
return _flippedX;
}
void Sprite::setFlippedY(bool flippedY)
{
if (_flippedY != flippedY)
{
_flippedY = flippedY;
flipY();
}
}
bool Sprite::isFlippedY(void) const
{
return _flippedY;
}
void Sprite::flipX() {
if (_renderMode == RenderMode::QUAD_BATCHNODE)
{
setDirty(true);
@ -1451,19 +1474,8 @@ void Sprite::setFlippedX(bool flippedX)
updatePoly();
}
}
}
bool Sprite::isFlippedX(void) const
{
return _flippedX;
}
void Sprite::setFlippedY(bool flippedY)
{
if (_flippedY != flippedY)
{
_flippedY = flippedY;
void Sprite::flipY() {
if (_renderMode == RenderMode::QUAD_BATCHNODE)
{
setDirty(true);
@ -1481,12 +1493,6 @@ void Sprite::setFlippedY(bool flippedY)
updatePoly();
}
}
}
bool Sprite::isFlippedY(void) const
{
return _flippedY;
}
//
// MARK: RGBA protocol
@ -1591,6 +1597,9 @@ void Sprite::setSpriteFrame(SpriteFrame *spriteFrame)
{
_polyInfo = spriteFrame->getPolygonInfo();
_renderMode = RenderMode::POLYGON;
if (_flippedX) flipX();
if (_flippedY) flipY();
updateColor();
}
if (spriteFrame->hasAnchorPoint())
{

View File

@ -661,6 +661,9 @@ protected:
void updatePoly();
void updateStretchFactor();
virtual void flipX();
virtual void flipY();
//
// Data used when the sprite is rendered using a SpriteSheet
//