-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPreloader.js
56 lines (39 loc) · 1.49 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
52
53
54
55
56
BasicGame.Preloader = function (game) {
this.bck = 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.preloadBar = this.add.sprite(this.world.centerX,this.world.centerY, 'preloaderBar');
this.preloadBar.anchor.setTo(0.5,0.5);
this.load.setPreloadSprite(this.preloadBar);
this.load.image('firebug','assets/fb.png');
this.load.image('firebuglight','assets/fblight.png');
this.load.image('tiles','assets/tiles.png');
this.load.image('title','assets/title.png');
this.load.image('enemy1','assets/enemy1.png');
this.load.image('flag','assets/flag.png');
this.load.spritesheet('skullbomb','assets/skullbombalive.png',200,200);
this.load.spritesheet('static','assets/static.png',500,450);
this.load.spritesheet('skullbombwhite','assets/skullbombwhite.png',200,200);
this.load.spritesheet('play','assets/play.png',107,41);
this.load.audio('titleMusic',['assets/music.mp3','assets/music.ogg']);
},
create: function () {
this.preloadBar.cropEnabled = false;
this.preloadBar.kill();
this.bck.kill();
this.decoding = this.add.sprite(this.world.centerX,this.world.centerY,'decoding');
this.decoding.anchor.setTo(0.5,0.5);
},
update: function () {
if (this.cache.isSoundDecoded('titleMusic') && this.ready == false)
{
this.ready = true;
this.state.start('MainMenu');
}
}
};