var ZYGameTool = require('GameTool'); var GameFaild = cc.Class({ extends: cc.Component, properties: { videoBtn: cc.Node, jumpBtn: cc.Node, btnCallFunc: null, numNode:cc.Node, number:8, }, // LIFE-CYCLE CALLBACKS: onLoad() { console.log("into GameFaild"); this.number = 8; this.schedule(this.countTime, 1); this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this); if (!Module.GameFaildLayer) Module.GameFaildLayer = this; this.videoBtn.on('click', function (event) { this.videoClick(); }.bind(this)); this.jumpBtn.on('click', function (event) { this.jumpClick(); }.bind(this)); ZYGameTool.getInstance().OpenAd("banner", "banner"); }, start() { }, countTime: function (){ --this.number; this.numNode.getComponent(cc.Label).string = this.number; if (this.number == 0) { this.jumpClick(); } if (this.number == 5){ this.jumpBtn.active =true; } }, videoClick: function () { this.unschedule(this.countTime); ZYGameTool.getInstance().OpenAd("home_lqjb", "video", function () { console.log("---debug---成功---"); if(this.btnCallFunc) this.btnCallFunc(true); Module.GameFaildLayer =null; this.node.destroy(); }.bind(this), function () { this.schedule(this.countTime, 1); // if(this.btnCallFunc) this.btnCallFunc(false); // Module.GameFaildLayer =null; // if (Module.GameManager) Module.GameManager.clearData(); // gameLocalData.clear(); // this.node.destroy(); // cc.director.loadScene("homeScene"); // console.log("---debug---失败---"); }.bind(this), ) }, jumpClick: function () { if(this.btnCallFunc) this.btnCallFunc(false); if (Module.GameManager) Module.GameManager.clearData(); gameLocalData.clear(); Module.GameFaildLayer =null; this.node.destroy(); cc.director.loadScene("homeScene"); }, call: function (func) { this.btnCallFunc = func; }, touchBegin: function (touch, event) { }, // update (dt) {}, });