@@ -610,9 +610,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
610610 * @param {Number } [scaleY=]
611611 */
612612 setScale : function ( scale , scaleY ) {
613- this . _scaleX = scale / cc . view . getDevicePixelRatio ( ) ;
614- this . _scaleY = ( ( scaleY || scaleY === 0 ) ? scaleY : scale ) /
615- cc . view . getDevicePixelRatio ( ) ;
613+ var ratio = cc . view . getDevicePixelRatio ( ) ;
614+ this . _scaleX = scale / ratio ;
615+ this . _scaleY = ( ( scaleY || scaleY === 0 ) ? scaleY : scale ) / ratio ;
616616 this . _renderCmd . setDirtyFlag ( cc . Node . _dirtyFlags . transformDirty ) ;
617617 } ,
618618
@@ -806,25 +806,37 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{
806806 getContentSize : function ( ) {
807807 if ( this . _needUpdateTexture )
808808 this . _renderCmd . _updateTTF ( ) ;
809- return cc . size (
810- this . _contentSize . width / cc . view . getDevicePixelRatio ( ) ,
811- this . _contentSize . height / cc . view . getDevicePixelRatio ( ) ) ;
809+ var ratio = cc . view . getDevicePixelRatio ( ) ;
810+ return cc . size ( this . _contentSize . width / ratio , this . _contentSize . height / ratio ) ;
812811 } ,
813812
814813 _getWidth : function ( ) {
815814 if ( this . _needUpdateTexture )
816815 this . _renderCmd . _updateTTF ( ) ;
817- return cc . Sprite . prototype . _getWidth . call ( this ) ;
816+ return this . _contentSize . width / cc . view . getDevicePixelRatio ( ) ;
818817 } ,
819818 _getHeight : function ( ) {
820819 if ( this . _needUpdateTexture )
821820 this . _renderCmd . _updateTTF ( ) ;
822- return cc . Sprite . prototype . _getHeight . call ( this ) ;
821+ return this . _contentSize . height / cc . view . getDevicePixelRatio ( ) ;
823822 } ,
824823
825824 setTextureRect : function ( rect , rotated , untrimmedSize ) {
826- //set needConvert to false
827- cc . Sprite . prototype . setTextureRect . call ( this , rect , rotated , untrimmedSize , false ) ;
825+ var _t = this ;
826+ _t . _rectRotated = rotated || false ;
827+ _t . setContentSize ( untrimmedSize || rect ) ;
828+
829+ _t . setVertexRect ( rect ) ;
830+ _t . _renderCmd . _setTextureCoords ( rect , false ) ;
831+
832+ var relativeOffsetX = _t . _unflippedOffsetPositionFromCenter . x , relativeOffsetY = _t . _unflippedOffsetPositionFromCenter . y ;
833+ if ( _t . _flippedX )
834+ relativeOffsetX = - relativeOffsetX ;
835+ if ( _t . _flippedY )
836+ relativeOffsetY = - relativeOffsetY ;
837+ var locRect = _t . _rect ;
838+ _t . _offsetPosition . x = relativeOffsetX + ( rect . width - locRect . width ) / 2 ;
839+ _t . _offsetPosition . y = relativeOffsetY + ( rect . height - locRect . height ) / 2 ;
828840 } ,
829841
830842 /**
0 commit comments