@@ -36,6 +36,9 @@ ccs.Label = ccs.Widget.extend(/** @lends ccs.Label# */{
3636 _fontSize : 0 ,
3737 _onSelectedScaleOffset : 0 ,
3838 _labelRenderer : "" ,
39+ _textAreaSize :null ,
40+ _textVerticalAlignment :0 ,
41+ _textHorizontalAlignment :0 ,
3942 ctor : function ( ) {
4043 ccs . Widget . prototype . ctor . call ( this ) ;
4144 this . _touchScaleChangeEnabled = false ;
@@ -45,6 +48,9 @@ ccs.Label = ccs.Widget.extend(/** @lends ccs.Label# */{
4548 this . _fontSize = 10 ;
4649 this . _onSelectedScaleOffset = 0.5 ;
4750 this . _labelRenderer = "" ;
51+ this . _textAreaSize = cc . size ( 0 , 0 ) ;
52+ this . _textVerticalAlignment = 0 ;
53+ this . _textHorizontalAlignment = 0 ;
4854 } ,
4955
5056 init : function ( ) {
@@ -110,6 +116,8 @@ ccs.Label = ccs.Widget.extend(/** @lends ccs.Label# */{
110116 * @param {cc.Size } size
111117 */
112118 setTextAreaSize : function ( size ) {
119+ this . _textAreaSize . width = size . width ;
120+ this . _textAreaSize . height = size . height ;
113121 this . _labelRenderer . setDimensions ( size ) ;
114122 this . labelScaleChangedWithSize ( ) ;
115123 } ,
@@ -119,6 +127,7 @@ ccs.Label = ccs.Widget.extend(/** @lends ccs.Label# */{
119127 * @param {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT } alignment Horizontal Alignment
120128 */
121129 setTextHorizontalAlignment : function ( alignment ) {
130+ this . _textHorizontalAlignment = alignment ;
122131 this . _labelRenderer . setHorizontalAlignment ( alignment ) ;
123132 this . labelScaleChangedWithSize ( ) ;
124133 } ,
@@ -128,6 +137,7 @@ ccs.Label = ccs.Widget.extend(/** @lends ccs.Label# */{
128137 * @param {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM } verticalAlignment
129138 */
130139 setTextVerticalAlignment : function ( alignment ) {
140+ this . _textVerticalAlignment = alignment ;
131141 this . _labelRenderer . setVerticalAlignment ( alignment ) ;
132142 this . labelScaleChangedWithSize ( ) ;
133143 } ,
@@ -301,7 +311,6 @@ ccs.Label = ccs.Widget.extend(/** @lends ccs.Label# */{
301311 this . _labelRenderer . setScaleX ( scaleX ) ;
302312 this . _labelRenderer . setScaleY ( scaleY ) ;
303313 }
304-
305314 } ,
306315
307316 /**
@@ -321,6 +330,9 @@ ccs.Label = ccs.Widget.extend(/** @lends ccs.Label# */{
321330 this . setFontSize ( uiLabel . _labelRenderer . getFontSize ( ) ) ;
322331 this . setText ( uiLabel . getStringValue ( ) ) ;
323332 this . setTouchScaleChangeEnabled ( uiLabel . _touchScaleChangeEnabled ) ;
333+ this . setTextAreaSize ( uiLabel . _size ) ;
334+ this . setTextHorizontalAlignment ( uiLabel . _textHorizontalAlignment ) ;
335+ this . setTextVerticalAlignment ( uiLabel . _textVerticalAlignment ) ;
324336 }
325337} ) ;
326338/**
0 commit comments