2ffc1791f05f73711b6e4e70b54292e6c6bcd653
[interactive-pacbot.git] / game / states / preload.js
1 'use strict';
2
3 function Preload() {
4   this.asset = null;
5   this.ready = false;
6 }
7
8 Preload.prototype = {
9   preload: function() {
10     this.asset = this.add.sprite(this.width/2,this.height/2, 'preloader');
11     this.asset.anchor.setTo(0.5, 0.5);
12
13     this.load.onLoadComplete.addOnce(this.onLoadComplete, this);
14     this.load.setPreloadSprite(this.asset);
15     this.load.image('wall', 'assets/images/wall.svg');
16     this.load.spritesheet('player-a', 'assets/images/player-a-spritesheet.svg', 100, 100);
17     this.load.spritesheet('player-b', 'assets/images/player-b-spritesheet.svg', 100, 100);
18     this.load.image('pill', 'assets/images/pill.svg');
19     this.load.image('bonus-pill', 'assets/images/bonus-pill.svg');
20
21     this.load.bitmapFont('spaced-scorefont', 'assets/fonts/scorefont.png', 'assets/fonts/scorefont.fnt', undefined, 10);
22     this.load.bitmapFont('scorefont', 'assets/fonts/scorefont.png', 'assets/fonts/scorefont.fnt');
23
24     this.load.text('level', 'assets/levels/maze.lvl');
25   },
26   create: function() {
27     this.asset.cropEnabled = false;
28   },
29   update: function() {
30     if(!!this.ready) {
31       this.game.state.start('play');
32     }
33   },
34   onLoadComplete: function() {
35     this.ready = true;
36   }
37 };
38
39 module.exports = Preload;