"use strict"; cc._RF.push(module, 'cbee6YrW2ZEGZV+yb6eTESk', 'scene.launch.h'); // Scripts/mod/login/h/scene.launch.h.js "use strict"; /****************************************************************** * * 启动动画 * ******************************************************************/ var BridgeWindow = require("bridge.window"); var NxSpine = require("nx.fx.spine"); var BridgeDefine = require("bridge.define"); var SFXS = ["boom", "down", "fire", "landing", "plane"]; cc.Class({ "extends": BridgeWindow, properties: { spAnim: { "default": null, type: NxSpine }, nodDialog: { "default": null, type: cc.Node }, nodSkip: { "default": null, type: cc.Node }, nodMask: { "default": null, type: cc.Node } }, // 载入 onLoad: function onLoad() { this.nodMask.active = false; }, // 显示 onEnable: function onEnable() { // 播放队列[动作名,文本,音频,播放速度,播放次数] this.queue = [["action1", "LaunchHWords1", "words1", 1.0, 4], ["action2", "LaunchHWords2", "words2", 1.0, 8], ["action3", "LaunchHWords3", "words3", 2.0, 8], ["action4", "LaunchHWords4", "words4", 1.0, 4]]; nx.gui.setActive(this.nodSkip, "", false); nx.gui.setActive(this.nodDialog, "", false); this.popNext(); // 预加载登录 this.preloadRes(); }, // 关闭 onDisable: function onDisable() { // 旁白 if (this.sfxWords) { nx.audio.stopSFX(this.sfxWords); this.sfxWords = 0; } }, // 下一步 popNext: function popNext() { var _this = this; if (nx.dt.arrEmpty(this.queue)) { this.nodSkip.active = false; this.doDone(2); return; } // 旁白 if (this.sfxWords) { nx.audio.stopSFX(this.sfxWords); this.sfxWords = 0; } // 播放动画 this.times = 0; this.cur = this.queue.shift(); this.spAnim.action(this.cur[0], true, function (_event) { _this.doEvent(_event); }, this.cur[3] || 1.0); // 对话出现 this.inWords(); // 延迟跳过 this.nodSkip.active = false; this.scheduleOnce(function () { _this.nodSkip.opacity = 0; _this.nodSkip.active = true; nx.tween.fadeIn(_this.nodSkip, "", 0.5); }, 2); }, // 事件处理 doEvent: function doEvent(_event) { nx.debug("$Event:", _event); // 音效 if (nx.dt.arrMember(SFXS, _event)) { var path = cc.path.join("prefab/login/h/audios", _event); nx.audio.playSFX(path, false); return; } // 跳过 // if( _event == "skip" ) { // nx.gui.setActive( this.nodSkip, "", true ); // return; // } // 完成 if (_event == "complete") { ++this.times; if (this.times == this.cur[4] - 1) { this.outWords(); return; } if (this.times == this.cur[4]) { this.popNext(); } return; } }, // 对话出现 inWords: function inWords() { var _this2 = this; var words = nx.text.getKey(this.cur[1]); nx.gui.setActive(this.nodDialog, "", true); nx.gui.setString(this.nodDialog, "txt", words); nx.tween.fadeIn(this.nodDialog, "", 0.1); // 旁白 if (this.sfxWords) { nx.audio.stopSFX(this.sfxWords); this.sfxWords = 0; } var path = cc.path.join("prefab/login/h/audios", this.cur[2]); nx.audio.playSFX(path, false, function (_err, _id) { _this2.sfxWords = _id; }); }, // 对话消失 outWords: function outWords() { var _this3 = this; nx.tween.fadeOut(this.nodDialog, "", 0.1, function () { nx.gui.setActive(_this3.nodDialog, "", false); }); }, // 结束 doDone: function doDone(_delay) { var _this4 = this; if (_delay === void 0) { _delay = 1; } this.nodMask.opacity = 0; this.nodMask.active = true; nx.tween.fadeIn(this.nodMask, "", _delay, function () { // 仅仅播放 var gs = nx.bridge.vget("GS"); if (gs == BridgeDefine.GameStage.Login) { _this4.close(); } else { nx.bridge.setGS(BridgeDefine.GameStage.Login); } }); }, // 点击跳过 onTouchSkip: function onTouchSkip() { this.popNext(); }, // 预加载登录 preloadRes: function preloadRes() { var path = cc.path.join("prefab/login", "scene_login"); nx.res.loadPrefab(path); } }); cc._RF.pop();