phaser/wip/TS Tests/template_breakout/Preloader.ts

35 lines
994 B
TypeScript

/// <reference path="phaser.d.ts" />
module BasicGame
{
export class Preloader extends Phaser.State {
background:Phaser.Sprite = null;
preloadBar:Phaser.Sprite = null;
ready:boolean = false;
preload():void {
this.background = this.add.sprite(0.0,0.0,"preloaderBackground");
this.preloadBar = this.add.sprite(300,400,"preloaderBar");
this.load.setPreloadSprite( this.preloadBar, 0 );
this.load.image("titlepage","assets/title.jpg",false);
this.load.image("playButton","assets/play_button.png",false);
this.load.audio("titleMusic",["assets/main_menu.mp3","assets/main_menu.ogg"],false);
this.load.atlas("breakout","assets/breakout.png","assets/breakout.json");
this.load.image("starfield","assets/starfield.jpg",false);
}
create():void {
this.preloadBar.cropEnabled = false;
}
update():void {
if( this.cache.isSoundDecoded("titleMusic") && this.ready == false )
{
this.ready = true;
this.game.state.start("MainMenu");
}
}
}
}