Bladeren bron

readygo重复

yichael 3 jaren geleden
bovenliggende
commit
d924a5d85f
3 gewijzigde bestanden met toevoegingen van 27 en 22 verwijderingen
  1. 7 17
      assets/Scripts/Game/GameMode.js
  2. 3 3
      assets/Scripts/Game/GameStates.js
  3. 17 2
      assets/Scripts/Game/PlayerController.js

+ 7 - 17
assets/Scripts/Game/GameMode.js

@@ -50,23 +50,9 @@ cc.Class({
     {
         this.TimeLabelScp.InitTime(this.GameStatesScp.totalTime);
     },
-    //页面退出回调
-    onQuit(data)
-    {
-        console.log('onQuit=',data);
-    },
-    //弹出框回调
-    onQuitModal(res)
-    {
-        if (res.data.confirm) {
-            console.log("退出");
-        }else if(res.data.cancel){
-            console.log("取消退出");
-        }
-    },
     StarGame(target,param)
     {
-        if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.ready) return; //1 ready to start
+        if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.default) return;
 
         this.GameStatesScp.progress = this.GameStatesScp.progressTag.ready; //1 ready to start
 
@@ -84,11 +70,15 @@ cc.Class({
 
             this.TimeLabelScp.CountDown(function(){
 
-                this.GameStatesScp.progress = this.GameStatesScp.progressTag.ready;
+                this.GameStatesScp.progress = this.GameStatesScp.progressTag.result;
                 this.GameStatesScp.PunchTimes = 0;
                 this.StartButtonNode.active = true;
                 this.TenSecondChallengeBG.active = true;
-                
+
+                this.scheduleOnce(function(){
+                    this.GameStatesScp.progress = this.GameStatesScp.progressTag.default;
+                }.bind(this),1);
+
             }.bind(this));
         }.bind(this));
         this.StartButtonNode.active = false;

+ 3 - 3
assets/Scripts/Game/GameStates.js

@@ -5,12 +5,12 @@ cc.Class({
       
     },
     onLoad () {
-        this.progress = 0;
+        this.progress = -1;
         this.progressTag = {
-            defalt: -1,
+            default: -1,
             ready: 0,
             start: 1,
-            finish: 2,
+            result: 2,
         };
   
         this.startPosition = {'x':0,'y':0};

+ 17 - 2
assets/Scripts/Game/PlayerController.js

@@ -71,13 +71,28 @@ cc.Class({
              self.node.on('onBoxingPostHit',self.onBoxingPostHit,self);
          });
     },
+    //页面退出回调
+    onQuit(data)
+    {
+        console.log('onQuit=',data);
+    },
+    //弹出框回调
+    onQuitModal(res)
+    {
+        if (res.data.confirm) {
+            console.log("退出");
+        }else if(res.data.cancel){
+            console.log("取消退出");
+        }
+    },
     onBoxingPostHit(data)
     {
-        if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.start)//2 start game
+        if(this.GameStatesScp.progress == this.GameStatesScp.progressTag.default)
         {
             this.GameModeScp.StarGame();
         }
-        else
+
+        if(this.GameStatesScp.progress == this.GameStatesScp.progressTag.start)
         {
             this.Run(1);
         }