@@ -635,7 +635,7 @@ cc.LayerRGBA = cc.Layer.extend(/** @lends cc.LayerRGBA# */{
635
635
* @param {Number } parentOpacity
636
636
*/
637
637
updateDisplayedOpacity : function ( parentOpacity ) {
638
- this . _displayedOpacity = this . _realOpacity * parentOpacity / 255.0 ;
638
+ this . _displayedOpacity = 0 | ( this . _realOpacity * parentOpacity / 255.0 ) ;
639
639
640
640
if ( this . _cascadeOpacityEnabled ) {
641
641
var locChildren = this . _children ;
@@ -656,37 +656,44 @@ cc.LayerRGBA = cc.Layer.extend(/** @lends cc.LayerRGBA# */{
656
656
} ,
657
657
658
658
getColor : function ( ) {
659
- return this . _realColor ;
659
+ var locRealColor = this . _realColor ;
660
+ return cc . c3b ( locRealColor . r , locRealColor . g , locRealColor . b ) ;
660
661
} ,
661
662
662
663
getDisplayedColor : function ( ) {
663
- return this . _displayedColor ;
664
+ var locDisplayedColor = this . _displayedColor ;
665
+ return cc . c3b ( locDisplayedColor . r , locDisplayedColor . g , locDisplayedColor . b ) ;
664
666
} ,
665
667
666
668
setColor : function ( color ) {
667
- this . _displayedColor = cc . c3b ( color . r , color . g , color . b ) ;
668
- this . _realColor = cc . c3b ( color . r , color . g , color . b ) ;
669
+ var locDisplayed = this . _displayedColor , locRealColor = this . _realColor ;
670
+ locDisplayed . r = locRealColor . r = color . r ;
671
+ locDisplayed . g = locRealColor . g = color . g ;
672
+ locDisplayed . b = locRealColor . b = color . b ;
669
673
670
674
if ( this . _cascadeColorEnabled ) {
671
- var parentColor = cc . white ( ) ;
675
+ var parentColor ;
672
676
var locParent = this . _parent ;
673
677
if ( locParent && locParent . RGBAProtocol && locParent . isCascadeColorEnabled ( ) )
674
678
parentColor = locParent . getDisplayedColor ( ) ;
679
+ else
680
+ parentColor = cc . white ( ) ;
675
681
this . updateDisplayedColor ( parentColor ) ;
676
682
}
677
683
} ,
678
684
679
685
updateDisplayedColor : function ( parentColor ) {
680
- this . _displayedColor . r = this . _realColor . r * parentColor . r / 255.0 ;
681
- this . _displayedColor . g = this . _realColor . g * parentColor . g / 255.0 ;
682
- this . _displayedColor . b = this . _realColor . b * parentColor . b / 255.0 ;
686
+ var locDisplayedColor = this . _displayedColor , locRealColor = this . _realColor ;
687
+ locDisplayedColor . r = 0 | ( locRealColor . r * parentColor . r / 255.0 ) ;
688
+ locDisplayedColor . g = 0 | ( locRealColor . g * parentColor . g / 255.0 ) ;
689
+ locDisplayedColor . b = 0 | ( locRealColor . b * parentColor . b / 255.0 ) ;
683
690
684
691
if ( this . _cascadeColorEnabled ) {
685
692
var locChildren = this . _children ;
686
693
for ( var i = 0 ; i < locChildren . length ; i ++ ) {
687
694
var selItem = locChildren [ i ] ;
688
695
if ( selItem && selItem . RGBAProtocol )
689
- selItem . updateDisplayedColor ( this . _displayedColor ) ;
696
+ selItem . updateDisplayedColor ( locDisplayedColor ) ;
690
697
}
691
698
}
692
699
} ,
@@ -786,15 +793,9 @@ cc.LayerColor = cc.LayerRGBA.extend(/** @lends cc.LayerColor# */{
786
793
_squareVerticesAB :null ,
787
794
_squareColorsAB :null ,
788
795
789
- /**
790
- * Constructor
791
- */
792
- ctor : null ,
793
-
794
796
_ctorForCanvas : function ( ) {
795
797
cc . LayerRGBA . prototype . ctor . call ( this ) ;
796
798
this . _blendFunc = new cc . BlendFunc ( cc . BLEND_SRC , cc . BLEND_DST ) ;
797
- this . _color = new cc . Color4B ( 0 , 0 , 0 , 0 ) ;
798
799
} ,
799
800
800
801
_ctorForWebGL : function ( ) {
@@ -1038,7 +1039,6 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{
1038
1039
ctor :function ( ) {
1039
1040
cc . LayerColor . prototype . ctor . call ( this ) ;
1040
1041
1041
- this . _color = new cc . Color3B ( 0 , 0 , 0 ) ;
1042
1042
this . _startColor = new cc . Color3B ( 0 , 0 , 0 ) ;
1043
1043
this . _endColor = new cc . Color3B ( 0 , 0 , 0 ) ;
1044
1044
this . _alongVector = cc . p ( 0 , - 1 ) ;
@@ -1053,7 +1053,7 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{
1053
1053
* @return {cc.Color3B }
1054
1054
*/
1055
1055
getStartColor :function ( ) {
1056
- return this . _color ;
1056
+ return this . _realColor ;
1057
1057
} ,
1058
1058
1059
1059
/**
@@ -1128,15 +1128,16 @@ cc.LayerGradient = cc.LayerColor.extend(/** @lends cc.LayerGradient# */{
1128
1128
* @param {cc.Point } Var
1129
1129
*/
1130
1130
setVector :function ( Var ) {
1131
- this . _alongVector = Var ;
1131
+ this . _alongVector . x = Var . x ;
1132
+ this . _alongVector . y = Var . y ;
1132
1133
this . _updateColor ( ) ;
1133
1134
} ,
1134
1135
1135
1136
/**
1136
1137
* @return {cc.Point }
1137
1138
*/
1138
1139
getVector :function ( ) {
1139
- return this . _alongVector ;
1140
+ return cc . p ( this . _alongVector . x , this . _alongVector . y ) ;
1140
1141
} ,
1141
1142
1142
1143
/** is Compressed Interpolation
0 commit comments