[]js进度,进度,js场景进度效果
new function() {
var className = 'Game';
window[className] = (function(original) {
function Class() {
this.arr = [
"res/atlas/lucky8.json",
"res/atlas/lucky8/lewinlineicons.json",
"res/atlas/lucky8/setting.json",
"res/atlas/lucky8/setView.json",
"res/atlas/lucky8/kj.json",
"res/atlas/lucky8/mh.json",
"res/atlas/lucky8/light.json",
"res/atlas/lucky8/jinbi.json",
"res/atlas/lucky8/bonus.json",
"res/atlas/lucky8/kuang.json",
"res/atlas/lucky8/dh/S.json",
"res/atlas/lucky8/dh/H1.json",
"res/atlas/lucky8/dh/H2.json",
"res/atlas/lucky8/dh/H3.json",
"res/atlas/lucky8/dh/W.json",
"res/atlas/lucky8/bonus.json",
];
this.init();
}
var p = Class.prototype;
p.init = function() {
//判断当前渲染模式是WebGL还是Canvas
if (Laya.Render.isWebGL) {
Laya.init(800, 600, Laya.WebGL);
Config.isAlpha = true; //设置画布是否透明,只对2D(WebGL)、3D有效。
Laya.stage.bgColor = "none"; //背景透明
} else {
Laya.init(800, 600);
Laya.stage.bgColor = null; //背景透明
}
//画布水平居中对齐
Laya.stage.alignH = Laya.Stage.ALIGN_CENTER;
//画布垂直居中对齐
Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
//设置适配模式
Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL;
//设置横竖屏
Laya.stage.screenMode = Laya.Stage.SCREEN_HORIZONTAL;
//显示帧频信息
Laya.Stat.show();
//预加载
Laya.loader.load(this.arr, Laya.Handler.create(this, this.onAssetLoaded), Laya.Handler.create(this, this.onLoading, null, false), Laya.Loader.ATLAS);
};
//加载完成后
p.onAssetLoaded = function() {};
//加载进度
p.onLoading = function(num) {
//先添加进度组件UI
if (!this.Progress) {
this.Progress = new Progress();
this.i = 0;
}
this.i++;
this.timeFn(this.i, num);
};
p.timeFn = function(i, num) {
//用定时延迟去加载进度 - 由于进度太快无法看到一个虚假的效果
Laya.timer.once(i * 100, this, function() {
this.Progress.schedule.value = num;
this.Progress.percentage.text = (num * 100).toFixed() + '%';
if (num >= 1) {
this.run();
}
});
};
p.run = function() {
Laya.timer.once(300, this, function() {//给一个延迟 1000ms进度场景
alert('进度加载完毕');
this.Progress.visible = false;
this.Start = new Start();
this.Start.zOrder = 2;//由于UI[b]编辑不能这只层级·需要用代码打..[/b]
})
}
return Class;
})();
}
var game = new Game();
没有找到相关结果
已邀请:
要回复问题请先登录
1 个回复
cuixueying
赞同来自: