/**
 * Created by Largoyle on 12/04/2014.
 */

/// <reference path="H:/Webpages/96ideas/Gamster/root/libs/phaser/build/phaser.d.ts" />

module BTSLD29 {

    export class Preloader extends Phaser.State {

        preloadBar: Phaser.Sprite;
        myLogo: Phaser.Sprite;

        preload() {

            //  Set-up our preloader sprite
            this.preloadBar = this.add.sprite(200, this.world.centerY+80, 'preloadBar');
            this.load.setPreloadSprite(this.preloadBar);

            // add logo
            this.myLogo = this.add.sprite(this.world.centerX-145, 150, 'logo');

        //  IMAGES
            this.load.image('titletext', 'assets/std/img/bts_title2.png');
            this.load.image('sirwalter', 'assets/SirWalterGrundlingTheThird.png');
            this.load.image('sirwalter_boat', 'assets/SirWalterGrundlingTheThird_boat.sh.png');
            this.load.image('scoreboard', 'assets/scoreboard.png');
            this.load.image('scorearrow', 'assets/score_arrow.png');
            this.load.image('leftright_bkgr', 'assets/bts_lr_bkgr_sm.png');
            this.game.load.spritesheet('leftright_waves', 'assets/waves_sm.png', 800, 20, 4);
            this.game.load.spritesheet('lvl1_tiles', 'assets/level/bts_lvl_tiles.png', 40, 40, 17);

        // SOUNDS
            this.game.load.audio('snd_boatmotor', [
                    'assets/sounds/boat_faster_2.mp3',
                    'assets/sounds/boat_faster_2.ogg']);
            this.game.load.audio('snd_ducks', [
                'assets/sounds/ducks2.mp3',
                'assets/sounds/ducks2.ogg']);

        // OBJECTS
            this.game.load.spritesheet('tiles_collectables', 'assets/obj_duck.png', 40, 40, 2);

//            this.load.image('logo', 'assets/logo.png');
//            this.load.audio('music', 'assets/title.mp3', true);
//            this.load.spritesheet('simon', 'assets/simon.png', 58, 96, 5);
//            this.load.image('level1', 'assets/level1.png');

        }

        create() {

            var tween = this.add.tween(this.preloadBar).to({ alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
            tween.onComplete.add(this.startMainMenu, this);

        }

        startMainMenu() {

            this.game.state.start('MainMenu', true, false);
            //this.game.state.start('Level1', true, false);

        }

    }

}

