[]分享-js资源进度加载


进度.gif

var ui_Socket: Socket;

// 程序入口
class GameMain {
//进度UI
Progress: Progress;
Socket: Socket;
arr = [
{ url: "images/1.jpg", type: Laya.Loader.IMAGE }
, { url: "images/2.jpg", type: Laya.Loader.IMAGE }
, { url: "images/3.jpg", type: Laya.Loader.IMAGE }
, { url: "images/4.png", type: Laya.Loader.IMAGE }
, { url: "images/5.jpg", type: Laya.Loader.IMAGE }
, { url: "images/6.jpg", type: Laya.Loader.IMAGE }
, { url: "images/7.jpg", type: Laya.Loader.IMAGE }
, { url: "images/8.jpg", type: Laya.Loader.IMAGE }
, { url: "video/mp3/SB02_SFX_BG01.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_BG02.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_BG03.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_BG04.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_BG05.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_BG06.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_payout1.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_payout2.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_payout3.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_spin.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/SB02_SFX_spin_stop.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/sfx_big_win.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/sfx_button.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/sfx_coin_fly.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/sfx_count_down.mp3", type: Laya.Loader.SOUND }
, { url: "video/mp3/sfx_twinkle_edited.mp3", type: Laya.Loader.SOUND }
];
constructor() {
// Config.isAlpha = true; //设置画布是否透明,只对2D(WebGL)、3D有效。
Laya.init(1280, 800, Laya.WebGL);
// Laya.stage.bgColor = "none"; //背景透明
//画布水平居中对齐
Laya.stage.alignH = Laya.Stage.ALIGN_CENTER;
//画布垂直居中对齐
Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
//设置适配模式
Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;
//设置横竖屏
Laya.stage.screenMode = 'none';
//显示帧频信息
Laya.Stat.show();
//加载进度ui
var arr = [{ url: "res/atlas/Progress.json", type: Laya.Loader.ATLAS }];
Laya.loader.load(arr, Laya.Handler.create(this, this.onProgress));
}
onProgress() {
this.Progress = new Progress();
Laya.stage.addChild(this.Progress);
//加载资源进度并且监听
Laya.loader.load(this.arr, Laya.Handler.create(this, this.onAssetsLoaded), Laya.Handler.create(this, this.onAssetsLoading, null, false));

}
onAssetsLoading(progress) {
this.Progress.changeBar(progress);
this.Progress.changeText(progress)
}
onAssetsLoaded() {
alert('加载完毕');
//====================
this.Socket = new Socket();
//====================
}
}
new GameMain();
已邀请:

wudi199553

赞同来自:

谢谢分享!

要回复问题请先

商务合作
商务合作