@@ -317,7 +317,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
317
317
// Shared data
318
318
//
319
319
// texture
320
- _rect :cc . rect ( 0 , 0 , 0 , 0 ) , //Retangle of cc.Texture2D
320
+ _rect :null , //Retangle of cc.Texture2D
321
321
_rectRotated :false , //Whether the texture is rotated
322
322
323
323
// Offset Position (used by Zwoptex)
@@ -524,7 +524,10 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
524
524
* @param {cc.Rect } rect
525
525
*/
526
526
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 ;
528
531
} ,
529
532
530
533
sortAllChildren :function ( ) {
@@ -915,6 +918,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
915
918
this . _offsetPosition = cc . p ( 0 , 0 ) ;
916
919
this . _unflippedOffsetPositionFromCenter = cc . p ( 0 , 0 ) ;
917
920
this . _blendFunc = { src : cc . BLEND_SRC , dst : cc . BLEND_DST } ;
921
+ this . _rect = cc . rect ( 0 , 0 , 0 , 0 ) ;
918
922
919
923
this . _quad = new cc . V3F_C4B_T2F_Quad ( ) ;
920
924
this . _quadWebBuffer = cc . renderContext . createBuffer ( ) ;
@@ -948,6 +952,7 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
948
952
this . _offsetPosition = cc . p ( 0 , 0 ) ;
949
953
this . _unflippedOffsetPositionFromCenter = cc . p ( 0 , 0 ) ;
950
954
this . _blendFunc = { src : cc . BLEND_SRC , dst : cc . BLEND_DST } ;
955
+ this . _rect = cc . rect ( 0 , 0 , 0 , 0 ) ;
951
956
952
957
this . _newTextureWhenChangeColor = false ;
953
958
this . _textureLoaded = true ;
@@ -1159,7 +1164,12 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
1159
1164
1160
1165
if ( ! locTextureLoaded ) {
1161
1166
this . _rectRotated = rotated || false ;
1162
- this . _rect = rect ;
1167
+ if ( ! rect ) {
1168
+ this . _rect . x = rect . x ;
1169
+ this . _rect . y = rect . y ;
1170
+ this . _rect . width = rect . width ;
1171
+ this . _rect . height = rect . height ;
1172
+ }
1163
1173
texture . addLoadedEventListener ( this . _textureLoadedCallback , this ) ;
1164
1174
return true ;
1165
1175
}
@@ -1211,7 +1221,12 @@ cc.Sprite = cc.NodeRGBA.extend(/** @lends cc.Sprite# */{
1211
1221
1212
1222
if ( ! locTextureLoaded ) {
1213
1223
this . _rectRotated = rotated || false ;
1214
- this . _rect = rect ;
1224
+ if ( ! rect ) {
1225
+ this . _rect . x = rect . x ;
1226
+ this . _rect . y = rect . y ;
1227
+ this . _rect . width = rect . width ;
1228
+ this . _rect . height = rect . height ;
1229
+ }
1215
1230
texture . addLoadedEventListener ( this . _textureLoadedCallback , this ) ;
1216
1231
return true ;
1217
1232
}
0 commit comments