Skip to content

Commit bc6f00c

Browse files
committed
Merge pull request #2401 from dingpinglv/develop
Fixed a bug of cc.Sprite that its flipped function is incorrect in Canvas
2 parents cccb378 + 7f1f232 commit bc6f00c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

cocos2d/core/base-nodes/CCNode.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,10 +2796,8 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
27962796
}
27972797

27982798
// adjust anchorPoint
2799-
if(!this._flippedX) //TODO modify for new renderer
2800-
t.tx += Cos * -appX * sx + -Sin * appY * sy;
2801-
if(!this._flippedY)
2802-
t.ty -= Sin * -appX * sx + Cos * appY * sy;
2799+
t.tx += Cos * -appX * sx + -Sin * appY * sy;
2800+
t.ty -= Sin * -appX * sx + Cos * appY * sy;
28032801

28042802
// if ignore anchorPoint
28052803
if (_t._ignoreAnchorPointForPosition) {

cocos2d/core/renderer/RendererCanvas.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,14 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
185185
if (blendChange)
186186
context.globalCompositeOperation = node._blendFuncStr;
187187

188-
if (node._flippedX)
188+
if (node._flippedX){
189+
locX = -locX - locWidth;
189190
context.scale(-1, 1);
190-
if (node._flippedY)
191+
}
192+
if (node._flippedY){
193+
locY = node._offsetPosition.y;
191194
context.scale(1, -1);
195+
}
192196

193197
if (node._texture) {
194198
image = node._texture._htmlElementObj;

0 commit comments

Comments
 (0)