代码拉取完成,页面将自动刷新
同步操作将从 Fengziii/p1 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
交流QQ群:65384669
「让做游戏变简单!」
本框架定位于简化游戏流程,提高团队开发效率,目前提供了管理模块间关系,处理底层事务,及松散的工具集合,使开发者专注于游戏本身的逻辑。
class Main extends egret.DisplayObjectContainer {
public constructor() {
super();
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
}
private onAddToStage(event: egret.Event) {
egret.lifecycle.addLifecycleListener((context) => {
// custom lifecycle plugin
context.onUpdate = () => {
}
})
egret.lifecycle.onPause = () => {
egret.ticker.pause();
}
egret.lifecycle.onResume = () => {
egret.ticker.resume();
}
//inject the custom material parser
//注入自定义的素材解析器
let assetAdapter = new AssetAdapter();
egret.registerImplementation("eui.IAssetAdapter", assetAdapter);
egret.registerImplementation("eui.IThemeAdapter", new ThemeAdapter());
core.Core.run(this.stage);
core.LayerCenter.getInstance().addLayer(LayerEnum.BG, new core.Layer());
core.LayerCenter.getInstance().addLayer(LayerEnum.UI, new core.EUILayer());
core.LayerCenter.getInstance().addLayer(LayerEnum.POPUP, new core.Layer());
core.LayerCenter.getInstance().addLayer(LayerEnum.LOADING, new core.EUILayer());
core.LayerCenter.getInstance().addLayer(LayerEnum.TOP, new core.Layer());
this.runGame().catch(e => {
console.log(e);
});
}
private async runGame() {
core.LoadingManager.setCurLoading(LoadingUI).show();
await this.loadResource()
await platform.login();
const userInfo = await platform.getUserInfo();
console.log(userInfo);
core.ResUtils.loadGroups(["preload"], this.onResourceProgress, this.onResourceLoadError, this.onResourceLoadComplete, this);
}
private async loadResource() {
try {
await RES.loadConfig("resource/default.res.json", "resource/");
await this.loadTheme();
}
catch (e) {
console.error(e);
}
}
private loadTheme() {
return new Promise((resolve, reject) => {
// load skin theme configuration file, you can manually modify the file. And replace the default skin.
//加载皮肤主题配置文件,可以手动修改这个文件。替换默认皮肤。
let theme = new eui.Theme("resource/default.thm.json", this.stage);
theme.addEventListener(eui.UIEvent.COMPLETE, () => {
resolve();
}, this);
})
}
/**
* 资源组加载进度
* @param {core.GroupData} data
*/
private onResourceProgress(data: core.GroupData): void {
egret.log(`当前加载进度:${data.curGroup} ${data.curGroupLoaded}/${data.curGroupTotal}`);
core.LoadingManager.getLoading(LoadingUI).setProgress(data);
}
/**
* 资源组加载出错
* @param {core.GroupData} data
*/
private onResourceLoadError(data: core.GroupData): void {
//TODO
egret.log("Group:" + data.curGroup + " has failed to load");
}
/**
* preload资源组加载完成
* @param {core.GroupData} data
*/
private onResourceLoadComplete(data: core.GroupData): void {
if (data.curGroup == 'preload') {
egret.log("Group:" + data.curGroup + " load complete");
core.LoadingManager.getLoading(LoadingUI).hide();
core.Config.init(RES.getRes('config_zip'));
this.initModule();
UIManager.instance.openModule(ModuleEnum.LOGIN);
}
}
private initModule(): void {
new GameModule();
new LoginModule();
new MainModule();
}
}
class LoginModule extends core.Module {
public constructor() {
super(ModuleEnum.LOGIN);
}
private m_pLoginUI: LoginUI;
/**
* 获取loading
*/
protected getLoading(): core.ILoadingUI {
return core.LoadingManager.getLoading(MainLoadingUI);
}
/**
* 预加载资源组
*/
protected getLoadGroup(data?: core.ModuleEventData): string[] {
return ['soundUI', 'animUI'];
}
/**
* 显示
*/
protected show(data?: any): void {
if (!this.m_pLoginUI) {
let loginUI: LoginUI = new LoginUI();
this.m_pLoginUI = loginUI;
}
core.LayerCenter.getInstance().getLayer(LayerEnum.UI).addChild(this.m_pLoginUI);
}
/**
* 隐藏
*/
protected hide(): void {
if (this.m_pLoginUI && this.m_pLoginUI.parent) {
this.m_pLoginUI.parent.removeChild(this.m_pLoginUI);
}
this.m_pLoginUI = null;
}
protected release(): void {
super.release();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。