"use strict"; cc._RF.push(module, 'b4832jM4s1Lz7CWmHqZPijI', 'ZY_GameScene'); // Script/ZY_GameScene.js "use strict"; var GameEvent = require('GameEvent'); var ZYGameTool = require('GameTool'); cc.Class({ "extends": cc.Component, properties: { gameManger: cc.Prefab, gamePauseLayer: cc.Prefab, helpNode: cc.Prefab, gameEndLayer: cc.Prefab, gameTipLyaer: cc.Prefab, _gameManger: null }, // LIFE-CYCLE CALLBACKS: onLoad: function onLoad() { this.createGameLayer(); }, start: function start() { var _this = this; cc.game.on(GameEvent.EventType.GANE_PAUSE, function () { _this.pauseClick(); }, this); cc.game.on(GameEvent.EventType.GANE_HELP, function () { _this.helpClick(); }, this); cc.game.on(GameEvent.EventType.GANE_FAIL, function () { _this.gameFaild(); }, this); cc.game.on(GameEvent.EventType.GAME_TIP, function () { _this.openTip(); }, this); }, createGameLayer: function createGameLayer() { if (this._gameManger) { this._gameMange.removeFromParent(); this._gameMange = null; } if (Module.GameManager) Module.GameManager = null; this._gameManger = cc.instantiate(this.gameManger); this._gameManger.parent = this.node; this._gameManger.setAnchorPoint(cc.v2(0.5, 0.5)); this._gameManger.setContentSize(cc.v2(0, 0)); this._gameManger.setPosition(cc.v2(0, 0)); }, //提示 openTip: function openTip() { var gameTip = cc.instantiate(this.gameTipLyaer); // console.log("-layer.width: " , gameTip.getChildByName("layer").width); gameTip.parent = this.node; gameTip.zIndex = 1000; Module.GameTipLayer.call(function (num) { if (num > 0) { Module.GameManager.txtTip("Congratulations on getting" + num + "gold coins"); } else { Module.GameManager.txtTip("Watch video failed, no gold coins"); } }.bind(this)); }, //失败 gameFaild: function gameFaild() { var gameFaildNode = cc.instantiate(this.gameEndLayer); gameFaildNode.zIndex = 100; gameFaildNode.parent = this.node; Module.GameFaildLayer.call(function (state) { console.log("state: ", state); if (state) { Module.GameManager.resurrenction(); } }.bind(this)); }, restStart: function restStart() { this._gameManger.removeFromParent(); this._gameManger = null; this.node.runAction(cc.sequence(cc.delayTime(0.2), cc.callFunc(function () { this.createGameLayer(); }.bind(this)))); }, pauseClick: function pauseClick() { var pauseLayer = cc.instantiate(this.gamePauseLayer); pauseLayer.parent = this.node; pauseLayer.zIndex = 1000; Module.GamePauseLayer.call(function (name) { gameLocalData.save(Module.GameManager); if (name === "backGameBtn") {} else if (name === "restGameBtn") { gameLocalData.clear(); this.restStart(); } else if (name === "backHomeBtn") { cc.director.loadScene("homeScene"); } }.bind(this)); }, helpClick: function helpClick() { var helpNode = cc.instantiate(this.helpNode); helpNode.parent = this.node; helpNode.zIndex = 1000; ZYGameTool.getInstance().setIntegerForKey(localDataItem.gameGuide, 0); Module.GameHelpLayer.setParam(false); } // update (dt) {}, }); cc._RF.pop();