@@ -237,7 +237,6 @@ cc.Scale9Sprite = cc.Node.extend({
237
237
initWithBatchNode :function ( batchNode , rect , unused , capInsets ) {
238
238
if ( batchNode ) {
239
239
this . updateWithBatchNode ( batchNode , rect , unused , capInsets ) ;
240
- this . setAnchorPoint ( cc . p ( 0.5 , 0.5 ) ) ;
241
240
}
242
241
this . m_positionsAreDirty = true ;
243
242
return true ;
@@ -377,16 +376,27 @@ cc.Scale9Sprite = cc.Node.extend({
377
376
this . _spriteRect = rect ;
378
377
this . _originalSize = new cc . Size ( rect . size . width , rect . size . height ) ;
379
378
this . _preferredSize = this . _originalSize ;
380
- this . _capInsetsInternal = capInsets ;
379
+ this . _capInsetsInternal = capInsets || cc . RectZero ( ) ;
381
380
382
381
// If there is no specified center region
383
- if ( cc . Rect . CCRectEqualToRect ( this . _capInsetsInternal , cc . RectZero ( ) ) ) {
382
+ if ( cc . Rect . CCRectEqualToRect ( this . _capInsetsInternal , cc . RectZero ( ) ) ||
383
+ cc . Rect . CCRectEqualToRect ( this . _capInsetsInternal , this . _spriteRect ) ) {
384
384
// Apply the 3x3 grid format
385
385
this . _capInsetsInternal = cc . RectMake (
386
386
rect . origin . x + this . _originalSize . width / 3 ,
387
387
rect . origin . y + this . _originalSize . height / 3 ,
388
388
this . _originalSize . width / 3 ,
389
389
this . _originalSize . height / 3 ) ;
390
+ this . _capInsets = null ;
391
+ }
392
+ else
393
+ {
394
+ this . _capInsetsInternal = cc . RectMake (
395
+ rect . origin . x + this . _capInsetsInternal . origin . x ,
396
+ rect . origin . y + this . _capInsetsInternal . origin . y ,
397
+ this . _capInsetsInternal . size . width ,
398
+ this . _capInsetsInternal . size . height
399
+ ) ;
390
400
}
391
401
392
402
// Get the image edges
@@ -456,6 +466,7 @@ cc.Scale9Sprite = cc.Node.extend({
456
466
457
467
this . setContentSize ( rect . size ) ;
458
468
this . addChild ( this . _scale9Image ) ;
469
+ this . setAnchorPoint ( cc . p ( 0.5 , 0.5 ) ) ;
459
470
return true ;
460
471
} ,
461
472
0 commit comments