cc.Class({ extends: cc.Component, properties: { speed:0, playerControllerScp:null, gameStatesScp:null, nameIndex:0 }, onLoad () { this.bMoving = true; this.bHightLight = false; this.bHit = false; //注册Touch事件 TOUCH_START TOUCH_END TOUCH_MOVE this.node.on(cc.Node.EventType.TOUCH_START,this.touchBegin,this); this.node.on(cc.Node.EventType.TOUCH_MOVE,this.touchBegin,this); this.node.on(cc.Node.EventType.TOUCH_END,this.touchBegin,this); this.actionBarWidth = 720; }, touchBegin:function(event) { this.hit(); }, update (dt) { if(this.bMoving) { this.node.x+=this.speed * dt * 30; if(this.node.x>this.actionBarWidth) // if(this.node.x>400) { this.bMoving = false; this.node.destroy(); return; } if(this.node.x >= -100 && this.node.x <= +100) // if(this.node.x >= -100 && this.node.x <= 100) { if(!this.bHightLight) { this.node.getChildByName('1').active = false; this.node.getChildByName('2').active = true; this.node.getChildByName('3').active = false; this.gameStatesScp.hightLightActionArr.push(this); this.bHightLight = true; } } if(this.node.x > 100) { if(this.bHightLight) { this.node.getChildByName('1').active = false; this.node.getChildByName('2').active = false; this.node.getChildByName('3').active = true; if(!this.bHit){ //如果没有打击,判断miss this.gameStatesScp.missCount ++; } for(let i=0;i