| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- let aGameInstance = require('GameInstance');
- let aWebView = require("WebView");
- 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,
- },
- 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.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();
- }
-
- },
- //页面退出回调
- onQuit(data)
- {
- console.log('onQuit=',data);
- },
- //弹出框回调
- onQuitModal(res)
- {
- if (res.data.confirm) {
- console.log("退出");
- }else if(res.data.cancel){
- console.log("取消退出");
- }
- },
- StarGame(target,param)
- {
- this.PlayerControllerScp.Reset();
- if(!this.ReadyGo.active)
- {
- this.ReadyGo.active = true;
- }
- this.ReadyGoScp.Play(function(){
- this.GameStatesScp.bStart = true;
- this.TimeLabelScp.CountDown({'second':10,'millisecond':0},function(){
- this.GameStatesScp.bStart = false;
- this.GameStatesScp.PunchTimes = 0;
- this.StartButtonNode.active = true;
- this.TenSecondChallengeBG.active = true;
- }.bind(this));
- }.bind(this));
- this.StartButtonNode.active = false;
- this.TenSecondChallengeBG.active = false;
- }
- });
|