Skip to content

Commit d965487

Browse files
committed
Closed #2833: Returning a new object instead returning an object's reference for some Engine class to avoid some mistake.
1 parent 967682f commit d965487

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

cocos2d/sprite_nodes/CCSprite.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,13 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
521521
* Do not call it manually. Use setTextureRect instead. <br/>
522522
* (override this method to generate "double scale" sprites)
523523
* </p>
524-
* @param rect
524+
* @param {cc.Rect} rect
525525
*/
526526
setVertexRect:function (rect) {
527-
this._rect = rect;
527+
this._rect.x = rect.x;
528+
this._rect.y = rect.y;
529+
this._rect.width = rect.width;
530+
this._rect.height = rect.height;
528531
},
529532

530533
sortAllChildren:function () {

cocos2d/sprite_nodes/CCSpriteFrame.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ cc.SpriteFrame = cc.Class.extend(/** @lends cc.SpriteFrame# */{
126126
* @return {cc.Rect}
127127
*/
128128
getRect:function () {
129-
return this._rect;
129+
var locRect = this._rect;
130+
return cc.rect(locRect.x, locRect.y, locRect.width, locRect.height);
130131
},
131132

132133
/**

0 commit comments

Comments
 (0)