Skip to content

Commit 5212350

Browse files
committed
Fixed #2416: fixed a bug of cc.Sprite in setTextureRect
1 parent e257247 commit 5212350

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cocos2d/core/labelttf/CCLabelTTF.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
642642
this._dimensions.width = width;
643643
this._dimensions.height = height;
644644
this._updateString();
645-
// Force udpate
645+
// Force update
646646
this._setUpdateTextureDirty();
647647
}
648648
},
@@ -654,7 +654,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
654654
if (width != this._dimensions.width) {
655655
this._dimensions.width = width;
656656
this._updateString();
657-
// Force udpate
657+
// Force update
658658
this._setUpdateTextureDirty();
659659
}
660660
},
@@ -666,7 +666,7 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
666666
if (height != this._dimensions.height) {
667667
this._dimensions.height = height;
668668
this._updateString();
669-
// Force udpate
669+
// Force update
670670
this._setUpdateTextureDirty();
671671
}
672672
},

cocos2d/core/sprites/CCSprite.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,14 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
759759
_t.setVertexRect(rect);
760760
_t._renderCmd._setTextureCoords(rect, needConvert);
761761

762-
var relativeOffset = _t._unflippedOffsetPositionFromCenter;
762+
var relativeOffsetX = _t._unflippedOffsetPositionFromCenter.x, relativeOffsetY = _t._unflippedOffsetPositionFromCenter.y;
763763
if (_t._flippedX)
764-
relativeOffset.x = -relativeOffset.x;
764+
relativeOffsetX = -relativeOffsetX;
765765
if (_t._flippedY)
766-
relativeOffset.y = -relativeOffset.y;
766+
relativeOffsetY = -relativeOffsetY;
767767
var locRect = _t._rect;
768-
_t._offsetPosition.x = relativeOffset.x + (_t._contentSize.width - locRect.width) / 2;
769-
_t._offsetPosition.y = relativeOffset.y + (_t._contentSize.height - locRect.height) / 2;
768+
_t._offsetPosition.x = relativeOffsetX + (_t._contentSize.width - locRect.width) / 2;
769+
_t._offsetPosition.y = relativeOffsetY + (_t._contentSize.height - locRect.height) / 2;
770770

771771
// rendering using batch node
772772
if (_t._batchNode) {

0 commit comments

Comments
 (0)