-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
52 lines (46 loc) · 1.21 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* eslint-disable */
;
(function () {
var config = {
showFPS: true,
dpi: 1.5
};
if (navigator.userAgent.toLowerCase().indexOf('mobile') != -1) {
config.width = window.innerWidth;
config.height = window.innerHeight;
}
Tiny.app = new Tiny.Application(config);
var main = {
init: function () {
console.log('init');
this.resourceLoad();
},
resourceLoad: function () {
var resources = [];
for (var key in RESOURCES) {
resources.push(RESOURCES[key]);
}
var progress = document.getElementById("progress");
var percent = document.getElementById("percent");
Tiny.Loader.run({
resources: resources,
onProgress: function (pre) {
console.log("percent:", pre + "%");
var num = ~~pre;
//更新UI
percent.innerHTML = num + "%";
progress.style.width = num + "%";
},
onAllComplete: function () {
console.log('all complete');
//clear DOM
var body = document.body;
body.removeChild(percent);
body.removeChild(progress.parentNode);
Tiny.app.run(new MainLayer());
}
});
}
};
main.init();
})();