From 9b148b08cd4d8cc2663a20c7a219fb9d171a3a32 Mon Sep 17 00:00:00 2001 From: fusijie Date: Wed, 5 Aug 2015 23:17:38 +0800 Subject: [PATCH] Fixed SpriteBatchNode setFlipped bug. --- cocos/2d/CCSprite.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index d48ced1a8d..925af0830e 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -282,6 +282,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) Sprite::Sprite(void) : _batchNode(nullptr) +, _textureAtlas(nullptr) , _shouldBeHidden(false) , _texture(nullptr) , _spriteFrame(nullptr) @@ -607,6 +608,16 @@ void Sprite::updateTransform(void) float x2 = x1 + size.width; float y2 = y1 + size.height; + + if (_flippedX) + { + std::swap(x1, x2); + } + if (_flippedY) + { + std::swap(y1, y2); + } + float x = _transformToBatch.m[12]; float y = _transformToBatch.m[13]; @@ -922,6 +933,9 @@ void Sprite::setFlippedX(bool flippedX) auto& v = _polyInfo.triangles.verts[i].vertices; v.x = _contentSize.width -v.x; } + if (_textureAtlas) { + setDirty(true); + } } } @@ -939,6 +953,9 @@ void Sprite::setFlippedY(bool flippedY) auto& v = _polyInfo.triangles.verts[i].vertices; v.y = _contentSize.height -v.y; } + if (_textureAtlas) { + setDirty(true); + } } }