Files
fc/dev/project/library/imports/58/58f8447a-43f2-452d-8223-2af6d8d7fb68.js
2026-05-24 10:21:26 +08:00

213 lines
5.1 KiB
JavaScript

"use strict";
cc._RF.push(module, '58f84R6Q/JFLYIjKvbY1/to', 'scene.launch.anim');
// Scripts/mod/login/scene/scene.launch.anim.js
"use strict";
/******************************************************************
*
* 启动动画
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var NxSpine = require("nx.fx.spine");
var BridgeDefine = require("bridge.define");
// const SFXS = [ "boom", "down", "fire", "landing", "plane", "sub" ];
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
}
},
// 显示
onEnable: function onEnable() {
// 播放队列
this.queue = [["launch1", "LaunchWords1", "words1"], ["launch2", "LaunchWords2", "words2"], ["launch3", "LaunchWords3", "words3"], ["launch4", "LaunchWords4", "words4"]];
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(0.5);
return;
}
// 旁白
if (this.sfxWords) {
nx.audio.stopSFX(this.sfxWords);
this.sfxWords = 0;
}
// 播放动画
this.cur = this.queue.shift();
var path = nx.res.fmtPath("prefab/login/spines/" + this.cur[0]);
this.spAnim.play(path, "action", function (_event) {
_this.doEvent(_event);
}, false);
// 延迟跳过
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 (_event == "sub") {
this.inWords();
}
// 对话消失
if (_event == "fadeout") {
this.outWords();
}
// 音效
if (nx.dt.arrMember(SFXS, _event)) {
var path = cc.path.join("prefab/login/audios", _event);
nx.audio.playSFX(path, false);
return;
}
// 跳过
// if( _event == "skip" ) {
// nx.gui.setActive( this.nodSkip, "", true );
// return;
// }
// 完成
if (_event == "complete") {
this.popNext();
return;
}
},
// 对话出现
inWords: function inWords() {
var _this2 = this;
var self = this;
var words = nx.text.getKey(this.cur[1]);
// let len = 0;
// let pop = function() {
// if( len >= words.length ) {
// return;
// }
// let output = words.substring( 0, ++len );
// nx.gui.setString( self.nodDialog, "txt", output );
// self.scheduleOnce( () => {
// pop();
// }, 0.08 );
// };
// this.nodDialog.scaleY = 0;
// this.nodDialog.opacity = 255;
nx.gui.setActive(this.nodDialog, "", true);
nx.gui.setString(this.nodDialog, "txt", words);
nx.tween.fadeIn(this.nodDialog, "", 1);
// nx.tween.scaleTo( this.nodDialog, "", 0.3, 1, 1, () => {
// pop();
// } );
// 旁白
if (this.sfxWords) {
nx.audio.stopSFX(this.sfxWords);
this.sfxWords = 0;
}
var path = cc.path.join("prefab/login/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.2, function () {
nx.gui.setActive(_this3.nodDialog, "", false);
});
},
// 结束
doDone: function doDone(_delay) {
if (_delay === void 0) {
_delay = 0.1;
}
// 仅仅播放
var gs = nx.bridge.vget("GS");
if (gs == BridgeDefine.GameStage.Login) {
this.close();
return;
}
// H播放
// if( this.needPlayH() ) {
// nx.storage.set( "FCLauchHTimes", 1 );
// this.scheduleOnce( () => {
// nx.bridge.setGS( BridgeDefine.GameStage.LaunchAnimH );
// }, 0.5 );
// return;
// }
// 登录
this.scheduleOnce(function () {
nx.bridge.setGS(BridgeDefine.GameStage.Login);
}, 0.5);
},
// 点击跳过
onTouchSkip: function onTouchSkip() {
this.popNext();
},
// 预加载登录
preloadRes: function preloadRes() {
var path = cc.path.join("prefab/login", "scene_login");
if (this.needPlayH()) {
path = cc.path.join("prefab/login/h", "scene_launch_h");
}
nx.res.loadPrefab(path);
},
// 需要H播放
needPlayH: function needPlayH() {
var hmod = nx.frame.vget("hMode");
var times = nx.storage.getNumber("FCLauchHTimes", 0);
if (!hmod || nx.dt.numPositive(times, false)) {
return false;
}
return true;
}
});
cc._RF.pop();