cc.Class({ extends: cc.Component, properties: { FadeTag : null }, start () { this.node.setLocalZOrder(999999); this.FadeTag = false; }, onload : function () { }, FadeInAndOut:function(callbackFadeIn,callbackFadeOut) { cc.log("准备黑屏",this.FadeTag); if (this.FadeTag) { return; } this.node.opacity=0; // this.FadeOut(10,function () { // // }.bind(this)); this.FadeTag = true; this.FadeIn(3,function () { if (callbackFadeIn != null) { callbackFadeIn(); } setTimeout(function () { this.FadeOut(3,function () { if (callbackFadeOut != null) { callbackFadeOut(); this.FadeTag = false; } }.bind(this)); }.bind(this),300); }.bind(this)); // this.FadeTag = true; }, // FadeInAndOutControl : function (tag) { // if (tag) { // this.node.opacity+=4; // }else { // // } // }, FadeIn:function(duration,fun) { var rate = duration/255; this.schedule(function() { if(this.node.opacity>=250) { if(this.node.opacity==255) { if(fun!=null) { fun(); } } this.node.opacity =255; return; } this.node.opacity +=5; }, rate,51); }, FadeOut:function(duration,fun) { var rate = duration/255; this.schedule(function() { if(this.node.opacity<=5) { if(this.node.opacity==0) { if(fun!=null) { this.node.opacity =0; fun(); } } this.node.opacity =0; return; } this.node.opacity -=5; }, rate,51); }, FadeInCallBack:function() { }, FadeOutCallBack:function() { }, // update :function(dt) { // // if (this.FadeTag != null) { // // this.FadeInAndOutControl(this.FadeTag); // // } // // }, });