Ver código fonte

修改项目结构以及跑步平滑

eraser 3 anos atrás
pai
commit
89d28f508b

+ 29 - 0
assets/Animations/Game/Punch.anim

@@ -0,0 +1,29 @@
+{
+  "__type__": "cc.AnimationClip",
+  "_name": "Punch",
+  "_objFlags": 0,
+  "_native": "",
+  "_duration": 0.16666666666666666,
+  "sample": 60,
+  "speed": 1,
+  "wrapMode": 1,
+  "curveData": {
+    "props": {
+      "x": [
+        {
+          "frame": 0,
+          "value": 0
+        },
+        {
+          "frame": 0.08333333333333333,
+          "value": 30
+        },
+        {
+          "frame": 0.16666666666666666,
+          "value": 0
+        }
+      ]
+    }
+  },
+  "events": []
+}

+ 6 - 0
assets/Animations/Game/Punch.anim.meta

@@ -0,0 +1,6 @@
+{
+  "ver": "2.1.2",
+  "uuid": "7dc61aed-1d2d-4b21-ab1c-b325d8fb9d1d",
+  "importer": "animation-clip",
+  "subMetas": {}
+}

Diferenças do arquivo suprimidas por serem muito extensas
+ 194 - 425
assets/Scenes/Game.fire


+ 0 - 27
assets/Scripts/Charactor.js

@@ -1,27 +0,0 @@
-cc.Class({
-    extends: cc.Component,
-
-    properties: {
-        
-    },
-    onLoad () {
-        this.anim = this.node.getComponent(sp.Skeleton);
-        this.anim.setCompleteListener(this.SpineEventCallback);
-    },
-    Run()
-    {
-        //this.anim.animation = 'run';// 要播放的动画名称【必填】
-        //this.anim.loop = true;// 是否循环
-        this.runAnim = this.anim.setAnimation(0, 'Run1', true);
-    },
-    Idel()
-    {
-        this.runAnim = this.anim.setAnimation(0, 'idle', true);
-    },
-    SpineEventCallback(trackEntry, loopCount)
-    {
-        if (trackEntry.animation.name === 'Run1') {
-            cc.log('Run1结束')
-        }
-    }
-});

+ 13 - 0
assets/Scripts/Game.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "4ee52368-802b-456b-9f82-773fdcf34f55",
+  "importer": "folder",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 58 - 0
assets/Scripts/Game/Charactor.js

@@ -0,0 +1,58 @@
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+        PlayerStatesNode: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
+    },
+    onLoad () {
+        this.PlayerStatesScp = this.PlayerStatesNode.getComponent('PlayerStates');
+        this.anim = this.node.getComponent(sp.Skeleton);
+        this.anim.setCompleteListener(this.SpineEventCallback);
+    },
+    Run(lv)
+    {
+        if(lv == this.PlayerStatesScp.state) return;
+
+        this.PlayerStatesScp.state = lv;
+
+        switch (lv) {
+            case 1:
+                //this.anim.animation = 'run';// 要播放的动画名称【必填】
+                //this.anim.loop = true;// 是否循环
+                this.runAnim = this.anim.setAnimation(0, 'Run1', true);
+                break;
+        
+            case 2:
+                //this.anim.animation = 'run';// 要播放的动画名称【必填】
+                //this.anim.loop = true;// 是否循环
+                this.runAnim = this.anim.setAnimation(0, 'Run2', true);
+                break;
+
+            case 3:
+                //this.anim.animation = 'run';// 要播放的动画名称【必填】
+                //this.anim.loop = true;// 是否循环
+                this.runAnim = this.anim.setAnimation(0, 'Run3', true);
+                break;
+            default:
+                break;
+        }
+    },
+    Idel()
+    {
+        if(this.PlayerStatesScp.state == this.PlayerStatesScp.stateTag.idle) return;
+
+        this.PlayerStatesScp.state = this.PlayerStatesScp.stateTag.idle;
+
+        this.runAnim = this.anim.setAnimation(0, 'idle', true);
+    },
+    SpineEventCallback(trackEntry, loopCount)
+    {
+        if (trackEntry.animation.name === 'Run1') {
+            //cc.log('Run1结束')
+        }
+    }
+});

+ 0 - 0
assets/Scripts/Charactor.js.meta → assets/Scripts/Game/Charactor.js.meta


+ 21 - 3
assets/Scripts/CountDown.js → assets/Scripts/Game/CountDown.js

@@ -13,10 +13,14 @@ cc.Class({
     {
         this.curtTime = {'second':0,'millisecond':0,'secondBase':60,'millisecondBase':60};
     },
-    CountDown(time,callback)
+    InitTime(time)
     {
+        this.TimeLabel.string = this.ShowTime(time);
         this.curtTime.second  = time.second;
         this.curtTime.millisecond  = time.millisecond;
+    },
+    CountDown(callback)
+    {
         let times = this.curtTime.second*this.curtTime.millisecondBase + this.curtTime.millisecond;
         times--;
         
@@ -43,13 +47,27 @@ cc.Class({
     },
     ShowTime(time)
     {
+        let second = '';
+        let millisecond = '';
+
+        if(time.second<10)
+        {
+            second ='0'+time.second;
+        }
+        else
+        {
+            second = time.second;
+        }
+
         if(time.millisecond<10)
         {
-            return '0'+this.curtTime.second + ':0' + this.curtTime.millisecond;
+            millisecond = '0' + time.millisecond;
         }
         else
         {
-            return '0'+this.curtTime.second + ':' + this.curtTime.millisecond;
+            millisecond = time.millisecond;
         }
+
+        return second+':'+millisecond;
     }
 });

+ 0 - 0
assets/Scripts/CountDown.js.meta → assets/Scripts/Game/CountDown.js.meta


+ 6 - 0
assets/Scripts/Game/GameInstance.js

@@ -0,0 +1,6 @@
+let GameInstance = 
+{
+   bFirstInGame:true,
+}
+
+module.exports = GameInstance;

+ 0 - 0
assets/Scripts/GameInstance.js.meta → assets/Scripts/Game/GameInstance.js.meta


+ 19 - 28
assets/Scripts/GameMode.js → assets/Scripts/Game/GameMode.js

@@ -1,5 +1,3 @@
-let aGameInstance = require('GameInstance');
-let aWebView = require("WebView");
 let aLib = require("Library");
 cc.Class({
     extends: cc.Component,
@@ -15,6 +13,11 @@ cc.Class({
             type: cc.Node, 
             serializable: true,
         },
+        MapNode: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
         TimeLabelNode: {
             default: null, 
             type: cc.Node, 
@@ -39,34 +42,13 @@ cc.Class({
     onLoad () {
         this.GameStatesScp = this.GameStates.getComponent('GameStates');
         this.PlayerControllerScp = this.PlayerControllerNode.getComponent('PlayerController');
+        this.MapScp = this.MapNode.getComponent('Map');
         this.TimeLabelScp = this.TimeLabelNode.getComponent('CountDown');
         this.ReadyGoScp = this.ReadyGo.getComponent('ReadyGo');
-
-        this.bStart = false;
     },
     start()
     {
-        //是否在pC
-        if(!aLib.isMobile()) return;
-
-        let self = this;
-
-        aWebView.init(self.node, ()=>{
-            aWebView.onBindHitBoxingPost();
-            self.node.on('onBoxingPostHit',self.onBoxingPostHit,self);
-        });
-    },
-    onBoxingPostHit(data)
-    {
-        if(!this.GameStatesScp.bStart)
-        {
-            this.StarGame();
-        }
-        else
-        {
-            this.PlayerControllerScp.Run();
-        }
-        
+        this.TimeLabelScp.InitTime(this.GameStatesScp.totalTime);
     },
     //页面退出回调
     onQuit(data)
@@ -84,20 +66,29 @@ cc.Class({
     },
     StarGame(target,param)
     {
+        if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.ready) return; //1 ready to start
+
+        this.GameStatesScp.progress = this.GameStatesScp.progressTag.ready; //1 ready to start
+
         this.PlayerControllerScp.Reset(); 
+        this.MapScp.Reset();
+        this.TimeLabelScp.InitTime(this.GameStatesScp.totalTime);
+
         if(!this.ReadyGo.active)
         {
             this.ReadyGo.active = true;
         }
 
         this.ReadyGoScp.Play(function(){
-            this.GameStatesScp.bStart = true;
+            this.GameStatesScp.progress = this.GameStatesScp.progressTag.start;//2 start
+
+            this.TimeLabelScp.CountDown(function(){
 
-            this.TimeLabelScp.CountDown({'second':10,'millisecond':0},function(){
-                this.GameStatesScp.bStart = false;
+                this.GameStatesScp.progress = this.GameStatesScp.progressTag.ready;
                 this.GameStatesScp.PunchTimes = 0;
                 this.StartButtonNode.active = true;
                 this.TenSecondChallengeBG.active = true;
+                
             }.bind(this));
         }.bind(this));
         this.StartButtonNode.active = false;

+ 0 - 0
assets/Scripts/GameMode.js.meta → assets/Scripts/Game/GameMode.js.meta


+ 21 - 0
assets/Scripts/Game/GameStates.js

@@ -0,0 +1,21 @@
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+      
+    },
+    onLoad () {
+        this.progress = 0;
+        this.progressTag = {
+            defalt: -1,
+            ready: 0,
+            start: 1,
+            finish: 2,
+        };
+  
+        this.startPosition = {'x':0,'y':0};
+        this.PunchTimes = 0;
+
+        this.totalTime = {'second':10,'millisecond':0,'secondBase':60,'millisecondBase':60};
+    },
+});

+ 0 - 0
assets/Scripts/GameStates.js.meta → assets/Scripts/Game/GameStates.js.meta


+ 71 - 0
assets/Scripts/Game/Map.js

@@ -0,0 +1,71 @@
+let aGameInstance = require('GameInstance');
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+        BGArr: {
+            default: [],
+            type: [cc.Node], 
+            serializable: true,   
+        },
+        PlayerNode: {
+            default: null,
+            type: cc.Node, 
+            serializable: true,   
+        },
+        BGSprite: {
+            default: null,
+            type: cc.SpriteFrame, 
+            serializable: true,   
+        },
+    },
+    onLoad () 
+    {
+        this.distance = 0;
+    },
+    Reset()
+    {
+        if(aGameInstance.bFirstInGame)
+        {
+            aGameInstance.bFirstInGame =false;
+            return;
+        }
+        
+        for(let i=0 ;i<3; i++)
+        {
+            //创建一个新的节点,因为cc.Sprite是组件不能直接挂载到节点上,只能添加到为节点的一个组件  
+            let node= new cc.Node('BG')  
+            //调用新建的node的addComponent函数,会返回一个sprite的对象  
+            const sprite = node.addComponent(cc.Sprite)  
+            //给sprite的spriteFrame属性 赋值  
+            sprite.spriteFrame=this.BGSprite;  
+
+            node.x = 720*i;
+            //把新的节点追加到self.node节点去。self.node,就是脚本挂载的节点  
+            this.node.addChild(node);
+        }
+    },
+    createMap()
+    {
+        //创建一个新的节点,因为cc.Sprite是组件不能直接挂载到节点上,只能添加到为节点的一个组件  
+        let node= new cc.Node('BG')  
+        //调用新建的node的addComponent函数,会返回一个sprite的对象  
+        const sprite = node.addComponent(cc.Sprite)  
+        //给sprite的spriteFrame属性 赋值  
+        sprite.spriteFrame=this.BGSprite;  
+
+        node.x = this.BGArr[2].x + 720;
+        //把新的节点追加到self.node节点去。self.node,就是脚本挂载的节点  
+        this.node.addChild(node);
+
+        return node;
+    },
+    update (dt) 
+    {
+        if(this.PlayerNode.x>this.BGArr[1].x)
+        {
+            this.BGArr.push(this.createMap());
+            this.BGArr.splice(0, 1);
+        }
+    },
+});

+ 0 - 0
assets/Scripts/Map.js.meta → assets/Scripts/Game/Map.js.meta


+ 184 - 0
assets/Scripts/Game/PlayerController.js

@@ -0,0 +1,184 @@
+let aWebView = require("WebView");
+let aLib = require("Library");
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+        GameMode: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
+        GameStates: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
+        PlayerNode: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
+        CharactorNode: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
+        PlayerStatesNode: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
+        PunchTimes: {
+            default: null, 
+            type: cc.Node, 
+            serializable: true,
+        },
+        PuchTimesLabel: {
+            default: null, 
+            type: cc.Label, 
+            serializable: true,
+        },
+    },
+    start () {
+        //初始化
+        this.GameModeScp = this.GameMode.getComponent('GameMode');
+        this.GameStatesScp = this.GameStates.getComponent('GameStates');
+        this.CharactorScp = this.CharactorNode.getComponent('Charactor');
+        this.PlayerStatesScp = this.PlayerStatesNode.getComponent('PlayerStates');
+        this.PunchTimesAnim = this.PunchTimes.getComponent(cc.Animation);
+        //触摸事件
+        this.TouchEventScp = this.PlayerNode.getComponent('TouchEvent');
+        this.TouchEventScp.registerListener(this.node);
+        this.node.on('touchstart',this.onEventStart,this);
+        //记录开始位置
+        this.GameStatesScp.startPosition.x = this.PlayerNode.x;
+        this.GameStatesScp.startPosition.y = this.PlayerNode.y;
+
+        this.PlayerStatesScp.state = this.PlayerStatesScp.stateTag.idle;//idle
+        //减慢玩家速度
+        this.schedule(function(){
+            this.SpeedDown();
+        }.bind(this),0.1,cc.macro.REPEAT_FOREVER);
+
+         //是否在pC
+         if(!aLib.isMobile()) return;
+
+         let self = this;
+ 
+         aWebView.init(self.node, ()=>{
+             aWebView.onBindHitBoxingPost();
+             self.node.on('onBoxingPostHit',self.onBoxingPostHit,self);
+         });
+    },
+    onBoxingPostHit(data)
+    {
+        if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.start)//2 start game
+        {
+            this.GameModeScp.StarGame();
+        }
+        else
+        {
+            this.Run(1);
+        }
+    },
+    onEventStart(worldPoint)
+    {
+        this.Run(0);
+    },
+    Run(bPunch)
+    {
+         //是否游戏开始
+         if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.start) return;
+
+        let time = new Date();
+        if(this.PlayerStatesScp.lastPucnTime!=0)
+        {
+            let dtTime = time.getMilliseconds() - this.PlayerStatesScp.lastPucnTime.getMilliseconds();
+
+            if(bPunch)
+            {
+                if(dtTime < 500)
+                {
+                    this.PlayerStatesScp.dtDownSpeed = 0.1;
+                }
+                else if(dtTime >= 500 && dtTime < 1000)
+                {
+                    this.PlayerStatesScp.dtDownSpeed = 0.2;
+                }
+                else if(dtTime >= 1000 && dtTime < 2000)
+                {
+                    this.PlayerStatesScp.dtDownSpeed = 0.5;
+                }
+            }
+            else
+            {
+                if(dtTime < 200)
+                {
+                    this.PlayerStatesScp.dtDownSpeed = 0.1;
+                }
+                else if(dtTime >= 200 && dtTime < 300)
+                {
+                    this.PlayerStatesScp.dtDownSpeed = 0.2;
+                }
+                else if(dtTime >= 300 && dtTime < 500)
+                {
+                    this.PlayerStatesScp.dtDownSpeed = 0.5;
+                }
+            }
+            
+        }
+        this.PlayerStatesScp.lastPucnTime = time;
+        this.GameStatesScp.PunchTimes++;
+        this.PuchTimesLabel.string = this.GameStatesScp.PunchTimes;
+
+        if(this.PlayerStatesScp.speed+this.PlayerStatesScp.dtSpeed<=10)
+        {
+            this.PlayerStatesScp.speed+=this.PlayerStatesScp.dtSpeed;
+        }
+        //console.log('this.PlayerStatesScp.speed=',this.PlayerStatesScp.speed)
+        this.unschedule(this.StopRun);
+        if(bPunch)
+        {
+            this.scheduleOnce(this.StopRun,2);
+        }
+        else
+        {
+            this.scheduleOnce(this.StopRun,0.5);
+        }
+    },
+    StopRun()
+    {
+        this.PlayerStatesScp.speed = 0;
+        this.CharactorScp.Idel();
+    },
+    SpeedDown()
+    {
+        if(this.PlayerStatesScp.speed<=0) return;
+        this.PlayerStatesScp.speed-=this.PlayerStatesScp.dtDownSpeed;
+    },
+    Reset()
+    {
+        this.PlayerNode.x = this.GameStatesScp.startPosition.x;
+        this.PlayerNode.y = this.GameStatesScp.startPosition.y;
+
+        this.PuchTimesLabel.string = '0';
+    },
+    update (dt) 
+    {
+        if(this.PlayerStatesScp.speed>0 && this.PlayerStatesScp.speed<3)//run
+        {
+            this.CharactorScp.Run(1);
+        }
+        else if(this.PlayerStatesScp.speed>=3 && this.PlayerStatesScp.speed<8)
+        {
+            this.CharactorScp.Run(2);
+        }
+        else if(this.PlayerStatesScp.speed>=9)
+        {
+            this.CharactorScp.Run(3);
+        }
+
+        this.PlayerNode.x += this.PlayerStatesScp.speed;
+    },
+});

+ 0 - 0
assets/Scripts/PlayerController.js.meta → assets/Scripts/Game/PlayerController.js.meta


+ 23 - 0
assets/Scripts/Game/PlayerStates.js

@@ -0,0 +1,23 @@
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+        
+    },
+    onLoad () {
+        this.state = 0;
+        this.stateTag = {
+            defalt: -1,
+            idle: 0,
+            run1: 1,
+            run2: 2,
+            run3: 3,
+        };
+
+        this.speed = 0;
+        this.dtSpeed = 0.5;
+        this.dtDownSpeed = 0.1;
+
+        this.lastPucnTime = 0;
+    },
+});

+ 10 - 0
assets/Scripts/Game/PlayerStates.js.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "c19938a1-41e7-4722-9ff2-f80785af7707",
+  "importer": "javascript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 0 - 0
assets/Scripts/ReadyGo.js → assets/Scripts/Game/ReadyGo.js


+ 0 - 0
assets/Scripts/ReadyGo.js.meta → assets/Scripts/Game/ReadyGo.js.meta


+ 0 - 38
assets/Scripts/GameInstance.js

@@ -1,38 +0,0 @@
-// Learn cc.Class:
-//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
-// Learn Attribute:
-//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
-// Learn life-cycle callbacks:
-//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
-
-cc.Class({
-    extends: cc.Component,
-
-    properties: {
-        // foo: {
-        //     // ATTRIBUTES:
-        //     default: null,        // The default value will be used only when the component attaching
-        //                           // to a node for the first time
-        //     type: cc.SpriteFrame, // optional, default is typeof default
-        //     serializable: true,   // optional, default is true
-        // },
-        // bar: {
-        //     get () {
-        //         return this._bar;
-        //     },
-        //     set (value) {
-        //         this._bar = value;
-        //     }
-        // },
-    },
-
-    // LIFE-CYCLE CALLBACKS:
-
-    // onLoad () {},
-
-    start () {
-
-    },
-
-    // update (dt) {},
-});

+ 0 - 17
assets/Scripts/GameStates.js

@@ -1,17 +0,0 @@
-cc.Class({
-    extends: cc.Component,
-
-    properties: {
-      
-    },
-    onLoad () {
-        this.bStart =false;
-        this.startPosition = {'x':0,'y':0};
-        this.PunchTimes = 0;
-    },
-    start () {
-
-    },
-
-    // update (dt) {},
-});

+ 0 - 28
assets/Scripts/Map.js

@@ -1,28 +0,0 @@
-cc.Class({
-    extends: cc.Component,
-
-    properties: {
-        BGArr: {
-            default: [],
-            type: [cc.Node], 
-            serializable: true,   
-        },
-        Player: {
-            default: null,
-            type: cc.Node, 
-            serializable: true,   
-        },
-    },
-    onLoad () 
-    {
-        this.distance = 0;
-    },
-    start () 
-    {
-
-    },
-    update (dt) 
-    {
-
-    },
-});

+ 0 - 108
assets/Scripts/PlayerController.js

@@ -1,108 +0,0 @@
-cc.Class({
-    extends: cc.Component,
-
-    properties: {
-        GameMode: {
-            default: null, 
-            type: cc.Node, 
-            serializable: true,
-        },
-        GameStates: {
-            default: null, 
-            type: cc.Node, 
-            serializable: true,
-        },
-        PlayerNode: {
-            default: null, 
-            type: cc.Node, 
-            serializable: true,
-        },
-        CharactorNode: {
-            default: null, 
-            type: cc.Node, 
-            serializable: true,
-        },
-        PuchTimesLabel: {
-            default: null, 
-            type: cc.Label, 
-            serializable: true,
-        },
-    },
-    start () {
-
-        this.GameModeScp = this.GameMode.getComponent('GameMode');
-        this.GameStatesScp = this.GameStates.getComponent('GameStates');
-        this.CharactorScp = this.CharactorNode.getComponent('Charactor');
-
-        this.TouchEventScp = cc.find('Canvas').getComponent('TouchEvent');
-        this.TouchEventScp.registerListener(this.node);
-        this.node.on('touchstart',this.onEventStart,this);
-        this.node.on('swipe',this.onEventSwipe,this);
-
-        this.GameStatesScp.startPosition.x = this.PlayerNode.x;
-        this.GameStatesScp.startPosition.y = this.PlayerNode.y;
-
-        this.bRuning = false;
-    },
-    onEventStart(worldPoint)
-    {
-        if(!this.GameStatesScp.bStart) return;
-        console.log('touch start');
-        this.Run();
-    },
-    onEventSwipe(direction)
-    {
-        if(!this.GameStatesScp.bStart) return;
-        if(direction == 'left')
-        {
-            //console.log('left');
-        }
-        else if(direction == 'right')
-        {
-            //console.log('right');
-        }
-        else if(direction == 'up')
-        {
-            //console.log('up');
-        }
-        else if(direction == 'down')
-        {
-            //console.log('down');
-        }
-    },
-    Run()
-    {
-        this.CharactorScp.Run();
-        this.PlayerNode.x+=3;
-        this.GameStatesScp.PunchTimes++;
-        this.PuchTimesLabel.string = this.GameStatesScp.PunchTimes;
-
-        this.unschedule(this.StopRun);
-        this.scheduleOnce(this.StopRun,0.5);
-    },
-    StopRun()
-    {
-        let count = 2;
-        this.schedule(function(){
-            if(!this.GameStatesScp.bStart)
-            {
-                this.CharactorScp.Idel();
-                return;
-            }
-
-            this.PlayerNode.x+=1;
-            count--;
-            if(count==0)
-            {
-                this.CharactorScp.Idel();
-            }
-        }.bind(this),0.1,count)
-    },
-    Reset()
-    {
-        this.PlayerNode.x = this.GameStatesScp.startPosition.x;
-        this.PlayerNode.y = this.GameStatesScp.startPosition.y;
-
-        this.PuchTimesLabel.string = '0';
-    }
-});

+ 14 - 0
assets/Scripts/TouchEvent.js

@@ -12,6 +12,7 @@ cc.Class({
         this.firstX = null;
         this.firsty = null;
         this.listenerArr = [];
+        this.touchTimes = 0;
     },
     registerEvent() {
         //touchstart 可以换成cc.Node.EventType.TOUCH_START
@@ -62,6 +63,19 @@ cc.Class({
         this.firstX = worldPoint.x;
         this.firstY = worldPoint.y;
 
+        this.touchTimes++;
+        if(this.touchTimes == 2)
+        {
+            this.touchTimes = 0;
+            this.dispatchEvent('doubletouch', worldPoint);
+        }
+        else
+        {
+            this.scheduleOnce(function(){
+                this.touchTimes = 0;
+            }.bind(this),0.2)
+        }
+
         this.dispatchEvent('touchstart', worldPoint);
     },
 

BIN
assets/Textures/Game/Punch.png


+ 38 - 0
assets/Textures/Game/Punch.png.meta

@@ -0,0 +1,38 @@
+{
+  "ver": "2.3.7",
+  "uuid": "e9acf2a9-f7c7-4b4d-b2b8-f7a3b709e905",
+  "importer": "texture",
+  "type": "sprite",
+  "wrapMode": "clamp",
+  "filterMode": "bilinear",
+  "premultiplyAlpha": false,
+  "genMipmaps": false,
+  "packable": true,
+  "width": 404,
+  "height": 464,
+  "platformSettings": {},
+  "subMetas": {
+    "Punch": {
+      "ver": "1.0.6",
+      "uuid": "e1773163-a072-4d18-afc0-47e2a4ef4db4",
+      "importer": "sprite-frame",
+      "rawTextureUuid": "e9acf2a9-f7c7-4b4d-b2b8-f7a3b709e905",
+      "trimType": "auto",
+      "trimThreshold": 1,
+      "rotated": false,
+      "offsetX": 0,
+      "offsetY": 0,
+      "trimX": 0,
+      "trimY": 0,
+      "width": 404,
+      "height": 464,
+      "rawWidth": 404,
+      "rawHeight": 464,
+      "borderTop": 0,
+      "borderBottom": 0,
+      "borderLeft": 0,
+      "borderRight": 0,
+      "subMetas": {}
+    }
+  }
+}

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff