let aLib = require("Library"); cc.Class({ extends: cc.Component, properties: { GameStates: { default: null, type: cc.Node, serializable: true, }, PlayerControllerNode: { default: null, type: cc.Node, serializable: true, }, MapNode: { default: null, type: cc.Node, serializable: true, }, TimeLabelNode: { default: null, type: cc.Node, serializable: true, }, StartButtonNode: { default: null, type: cc.Node, serializable: true, }, TenSecondChallengeBG: { default: null, type: cc.Node, serializable: true, }, ReadyGo: { default: null, type: cc.Node, serializable: true, }, }, 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'); }, start() { this.TimeLabelScp.InitTime(this.GameStatesScp.totalTime); }, StarGame(target,param) { if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.default) return; 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.progress = this.GameStatesScp.progressTag.start;//2 start this.TimeLabelScp.CountDown(function(){ 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; this.TenSecondChallengeBG.active = false; } });