/**
* 资源管理
*/
class RESMgr {
private static instance:RESMgr;
public static get Instance():RESMgr
{
if(this.instance==null)
{
this.instance = new RESMgr();
}
return this.instance;
}
private loadConfigCompleteFunc:Function;
private loadGroupCompleteFunc:Function;
/**
* 加载配置文件
*/
public loadConfig(loadConfigCompleteFunc?:Function):Promise<void>
{
this.loadConfigCompleteFunc = loadConfigCompleteFunc;
//添加资源配置加载完成事件
RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this);
//加载配置
return RES.loadConfig("resource/default.res.json", "resource/");
}
/**
* 配置文件加载完成,开始预加载preload资源组。
*/
private onConfigComplete(event:RES.ResourceEvent):void
{
RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this);
if(this.loadConfigCompleteFunc)
{
this.loadConfi
egret 资源管理
最新推荐文章于 2025-06-07 12:56:58 发布