-
Notifications
You must be signed in to change notification settings - Fork 21
/
Preloader.js
51 lines (29 loc) · 1.04 KB
/
Preloader.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
BasicGame.Preloader = function (game) {
this.background = null;
this.preloadBar = null;
this.ready = false;
};
BasicGame.Preloader.prototype = {
preload: function () {
this.bck = this.add.sprite(this.world.centerX, this.world.centerY, 'preloaderBackground');
this.bck.anchor.setTo(0.5,0.5);
this.bck.scale.setTo(0.5,0.5);
this.preloadBar = this.add.sprite(this.world.centerX, this.world.centerY, 'preloaderBar');
this.preloadBar.anchor.setTo(0,0.5);
this.preloadBar.scale.setTo(0.5,1);
this.preloadBar.x = this.world.centerX - this.preloadBar.width/2;
this.load.setPreloadSprite(this.preloadBar);
this.load.atlas('spriteset', 'assets/spriteset.png', 'assets/spriteset.jsona');
this.load.audio('music', ['assets/music.mp3','assets/music.ogg','assets/music.wav','assets/music.m4a']);
},
create: function () {
this.preloadBar.cropEnabled = false;
},
update: function () {
if (this.cache.isSoundDecoded('music') && this.ready == false)
{
this.ready = true;
this.state.start('Game');
}
}
};