@@ -237,7 +237,6 @@ cc.Scale9Sprite = cc.Node.extend({
237237 initWithBatchNode :function ( batchNode , rect , unused , capInsets ) {
238238 if ( batchNode ) {
239239 this . updateWithBatchNode ( batchNode , rect , unused , capInsets ) ;
240- this . setAnchorPoint ( cc . p ( 0.5 , 0.5 ) ) ;
241240 }
242241 this . m_positionsAreDirty = true ;
243242 return true ;
@@ -377,16 +376,27 @@ cc.Scale9Sprite = cc.Node.extend({
377376 this . _spriteRect = rect ;
378377 this . _originalSize = new cc . Size ( rect . size . width , rect . size . height ) ;
379378 this . _preferredSize = this . _originalSize ;
380- this . _capInsetsInternal = capInsets ;
379+ this . _capInsetsInternal = capInsets || cc . RectZero ( ) ;
381380
382381 // 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 ) ) {
384384 // Apply the 3x3 grid format
385385 this . _capInsetsInternal = cc . RectMake (
386386 rect . origin . x + this . _originalSize . width / 3 ,
387387 rect . origin . y + this . _originalSize . height / 3 ,
388388 this . _originalSize . width / 3 ,
389389 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+ ) ;
390400 }
391401
392402 // Get the image edges
@@ -456,6 +466,7 @@ cc.Scale9Sprite = cc.Node.extend({
456466
457467 this . setContentSize ( rect . size ) ;
458468 this . addChild ( this . _scale9Image ) ;
469+ this . setAnchorPoint ( cc . p ( 0.5 , 0.5 ) ) ;
459470 return true ;
460471 } ,
461472
0 commit comments