@@ -241,8 +241,8 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{
241241 this . _disabledColor = cc . color ( 126 , 126 , 126 ) ;
242242 this . setLabel ( label ) ;
243243
244- this . cascadeColor = true ;
245- this . cascadeOpacity = true ;
244+ this . setCascadeColorEnabled ( true ) ;
245+ this . setCascadeOpacityEnabled ( true ) ;
246246 }
247247 } ,
248248
@@ -281,6 +281,7 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{
281281 label . anchorY = 0 ;
282282 this . width = label . width ;
283283 this . height = label . height ;
284+ label . setCascadeColorEnabled ( true ) ;
284285 }
285286
286287 if ( this . _label ) {
@@ -296,49 +297,16 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{
296297 */
297298 setEnabled : function ( enabled ) {
298299 if ( this . _enabled !== enabled ) {
299- var locLabel = this . _label ;
300300 if ( ! enabled ) {
301- this . _colorBackup = locLabel . color ;
302- locLabel . color = this . _disabledColor ;
301+ this . _colorBackup = this . color ;
302+ this . setColor ( this . _disabledColor ) ;
303303 } else {
304- locLabel . color = this . _colorBackup ;
304+ this . setColor ( this . _colorBackup ) ;
305305 }
306306 }
307307 cc . MenuItem . prototype . setEnabled . call ( this , enabled ) ;
308308 } ,
309309
310- /**
311- * set opacity for cc.MenuItemLabel
312- * @param {Number } opacity from 0-255
313- */
314- setOpacity : function ( opacity ) {
315- this . _label . opacity = opacity ;
316- } ,
317-
318- /**
319- * return the opacity of cc.MenuItemLabel
320- * @return {Number }
321- */
322- getOpacity : function ( ) {
323- return this . _label . opacity ;
324- } ,
325-
326- /**
327- * set the opacity for cc.MenuItemLabel
328- * @param {cc.Color } color
329- */
330- setColor : function ( color ) {
331- this . _label . color = color ;
332- } ,
333-
334- /**
335- * return the color of cc.MenuItemLabel
336- * @return {cc.Color }
337- */
338- getColor : function ( ) {
339- return this . _label . color ;
340- } ,
341-
342310 /**
343311 * initializes a cc.MenuItemLabel with a label
344312 * @param {cc.Node } label
@@ -353,8 +321,8 @@ cc.MenuItemLabel = cc.MenuItem.extend(/** @lends cc.MenuItemLabel# */{
353321 this . _disabledColor = cc . color ( 126 , 126 , 126 ) ;
354322 this . setLabel ( label ) ;
355323
356- this . cascadeColor = true ;
357- this . cascadeOpacity = true ;
324+ this . setCascadeColorEnabled ( true ) ;
325+ this . setCascadeOpacityEnabled ( true ) ;
358326
359327 return true ;
360328 } ,
@@ -867,60 +835,16 @@ cc.MenuItemSprite = cc.MenuItem.extend(/** @lends cc.MenuItemSprite# */{
867835 locNormalImage . addEventListener ( "load" , function ( sender ) {
868836 this . width = sender . width ;
869837 this . height = sender . height ;
870- this . cascadeColor = true ;
871- this . cascadeOpacity = true ;
838+ this . setCascadeColorEnabled ( true ) ;
839+ this . setCascadeOpacityEnabled ( true ) ;
872840 } , this ) ;
873841 }
874842 }
875- this . cascadeColor = true ;
876- this . cascadeOpacity = true ;
843+ this . setCascadeColorEnabled ( true ) ;
844+ this . setCascadeOpacityEnabled ( true ) ;
877845 return true ;
878846 } ,
879847
880- /**
881- * set the color for cc.MenuItemSprite
882- * @param {cc.Color } color
883- */
884- setColor : function ( color ) {
885- this . _normalImage . color = color ;
886-
887- if ( this . _selectedImage )
888- this . _selectedImage . color = color ;
889-
890- if ( this . _disabledImage )
891- this . _disabledImage . color = color ;
892- } ,
893-
894- /**
895- * return the color of cc.MenuItemSprite
896- * @return {cc.Color }
897- */
898- getColor : function ( ) {
899- return this . _normalImage . color ;
900- } ,
901-
902- /**
903- * set the opacity for cc.MenuItemSprite
904- * @param {Number } opacity 0 - 255
905- */
906- setOpacity : function ( opacity ) {
907- this . _normalImage . opacity = opacity ;
908-
909- if ( this . _selectedImage )
910- this . _selectedImage . opacity = opacity ;
911-
912- if ( this . _disabledImage )
913- this . _disabledImage . opacity = opacity ;
914- } ,
915-
916- /**
917- * return the opacity of cc.MenuItemSprite
918- * @return {Number } opacity from 0 - 255
919- */
920- getOpacity : function ( ) {
921- return this . _normalImage . opacity ;
922- } ,
923-
924848 /**
925849 * menu item is selected (runs callback)
926850 */
@@ -1311,8 +1235,8 @@ cc.MenuItemToggle = cc.MenuItem.extend(/** @lends cc.MenuItemToggle# */{
13111235 this . _selectedIndex = cc . UINT_MAX ;
13121236 this . setSelectedIndex ( 0 ) ;
13131237
1314- this . cascadeColor = true ;
1315- this . cascadeOpacity = true ;
1238+ this . setCascadeColorEnabled ( true ) ;
1239+ this . setCascadeOpacityEnabled ( true ) ;
13161240
13171241 return true ;
13181242 } ,
0 commit comments