|
|
@@ -51,14 +51,10 @@ cc.Class({
|
|
|
|
|
|
//初始化
|
|
|
this.bTimerStart = false;//0停止 1开始
|
|
|
- this.bRunScene = true;
|
|
|
- this.bPunchCD = true;
|
|
|
+ this.bRunScene = false;
|
|
|
+ this.bPunchCD = false;
|
|
|
this.btnCD = false;
|
|
|
|
|
|
- this.AudioControllerScp.playBGM('Game/Audios/BGM/Funny.wav',1,()=>{
|
|
|
- this.bRunScene = false;
|
|
|
- });
|
|
|
-
|
|
|
switch (aGameInstance.sceneIdx) {
|
|
|
case 0:
|
|
|
this.aGameStates.targetTime.second = 3;
|
|
|
@@ -89,55 +85,29 @@ cc.Class({
|
|
|
},
|
|
|
start()
|
|
|
{
|
|
|
- this.scheduleOnce(function(){
|
|
|
- this.bPunchCD = false;
|
|
|
- },2);
|
|
|
-
|
|
|
- if(aGameInstance.bInit)
|
|
|
- {
|
|
|
- webView.register(this.node);
|
|
|
- webView.onBindHitBoxingPost();
|
|
|
- self.node.on('onBoxingPostHit',this.onBoxingPostHit,this);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- aGameInstance.bInit =false;
|
|
|
+ //是否在pC
|
|
|
+ if(!lib.isMobile()) return;
|
|
|
+
|
|
|
let self = this;
|
|
|
- webView.init(this.node, ()=>{
|
|
|
+
|
|
|
+ self.bPunchCD = true;
|
|
|
+ self.scheduleOnce(()=>{
|
|
|
+ self.bPunchCD = false;
|
|
|
+ },2);
|
|
|
+
|
|
|
+ self.bRunScene = true;
|
|
|
+ self.AudioControllerScp.playBGM('Game/Audios/BGM/Funny.wav',1,()=>{
|
|
|
+ self.bRunScene = false;
|
|
|
+ });
|
|
|
+
|
|
|
+ webView.init(self.node, ()=>{
|
|
|
webView.onBindHitBoxingPost();
|
|
|
self.node.on('onBoxingPostHit',self.onBoxingPostHit,self);
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
- // if(cc.sys.isMobile)
|
|
|
- // {
|
|
|
- // let self = this;
|
|
|
- // //init web sdk
|
|
|
- // if (lib.openInWebview())
|
|
|
- // {
|
|
|
- // // 在app内Webview打开
|
|
|
- // webView.init(this.node,()=>{
|
|
|
- // webView.onBindHitBoxingPost();
|
|
|
- // webView.onAddQuitModalListener();//添加退出事件
|
|
|
- // self.node.on('onBoxingPostHit',self.onBoxingPostHit,self);
|
|
|
- // self.node.on('onQuit',self.onQuit,self);
|
|
|
- // self.node.on('onQuitModal',self.onQuitModal,self);
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }
|
|
|
},
|
|
|
onBoxingPostHit(data)
|
|
|
{
|
|
|
- if(this.bPunchCD)
|
|
|
- {
|
|
|
- this.scheduleOnce(function(){
|
|
|
- this.bPunchCD = false;
|
|
|
- },2);
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
this.Punch();
|
|
|
- this.bPunchCD = true;
|
|
|
},
|
|
|
//页面退出回调
|
|
|
onQuit(data)
|
|
|
@@ -163,7 +133,13 @@ cc.Class({
|
|
|
this.AudioControllerScp.stopAll();
|
|
|
//取消这个组件得所有计时器
|
|
|
this.unscheduleAllCallbacks();
|
|
|
- webView.unRegister(this.node);
|
|
|
+
|
|
|
+ //是否在pC
|
|
|
+ if(lib.isMobile()){
|
|
|
+ webView.onUnbindHitBoxingPost();
|
|
|
+ webView.unRegister(this.node);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
this.scheduleOnce(()=>{
|
|
|
cc.director.loadScene("Menu");
|
|
|
@@ -175,6 +151,10 @@ cc.Class({
|
|
|
},
|
|
|
Punch()
|
|
|
{
|
|
|
+ if(this.bPunchCD) return;
|
|
|
+
|
|
|
+ this.bPunchCD = true;
|
|
|
+
|
|
|
let target = this.StartOrStopButton;
|
|
|
switch (aGameInstance.sceneIdx) {
|
|
|
case 0:
|
|
|
@@ -193,6 +173,7 @@ cc.Class({
|
|
|
target.active = true;
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
else
|
|
|
@@ -202,6 +183,7 @@ cc.Class({
|
|
|
target.active = true;
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
}
|
|
|
@@ -233,6 +215,7 @@ cc.Class({
|
|
|
target.active = true;
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
else
|
|
|
@@ -242,6 +225,7 @@ cc.Class({
|
|
|
target.active = true;
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
}
|
|
|
@@ -283,6 +267,7 @@ cc.Class({
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
this.TargetTimeLabel.string = '';
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
else
|
|
|
@@ -305,6 +290,7 @@ cc.Class({
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
this.TargetTimeLabel.string = '';
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
}
|
|
|
@@ -348,6 +334,7 @@ cc.Class({
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
this.TargetTimeLabel.string = '';
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
else
|
|
|
@@ -370,6 +357,7 @@ cc.Class({
|
|
|
this.ResultScp.ShutDown();
|
|
|
this.TrumpAnimScp.StartAnim();
|
|
|
this.TargetTimeLabel.string = '';
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
}
|
|
|
}
|
|
|
@@ -394,7 +382,10 @@ cc.Class({
|
|
|
this.AudioControllerScp.playBGM('Game/Audios/BGM/CountTime.wav',0.5,()=>{
|
|
|
this.bRunScene = false;
|
|
|
});
|
|
|
- //this.TrumpAnimScp.StartAnim();
|
|
|
+
|
|
|
+ this.scheduleOnce(function(){
|
|
|
+ this.bPunchCD = false;
|
|
|
+ },1);
|
|
|
|
|
|
this.aGameStates.curtTime.second = 0;
|
|
|
this.aGameStates.curtTime.millisecond = 0;
|
|
|
@@ -513,6 +504,7 @@ cc.Class({
|
|
|
},
|
|
|
TimeUp()
|
|
|
{
|
|
|
+ this.bPunchCD = true;
|
|
|
this.StartOrStopButton.active = false;
|
|
|
this.StopTimer();
|
|
|
this.TrumpAnimScp.StopAnim();
|
|
|
@@ -523,8 +515,9 @@ cc.Class({
|
|
|
this.bTimerStart = false;//0停止 1开始
|
|
|
this.StartOrStopButton.active = true;
|
|
|
this.ResultScp.ShutDown();
|
|
|
-this.TrumpAnimScp.StartAnim();
|
|
|
+ this.TrumpAnimScp.StartAnim();
|
|
|
this.StartOrStopButton.getChildByName("Background").getChildByName("Label").getComponent(cc.Label).string = 'RESTART';
|
|
|
+ this.bPunchCD = false;
|
|
|
}.bind(this));
|
|
|
},
|
|
|
StopTimer()
|