/*
 * Preload state
 * =============
 *
 * This state takes care of loading the main game assets, including graphics
 * and sound effects, while displaying a splash screen with a progress bar,
 * showing how much progress were made during the asset load.
 */

import assets from '../assets';

export default class Preload extends Phaser.State {

    preload() {
        this.showSplashScreen();
        this.loadAssets();
        this.game.stage.backgroundColor = '#A7BAB9';
    }

    create() {
        // Here is a good place to initialize plugins that depend on any game
        // asset. Example:
        //this.add.plugin(MyPlugin/*, ... initialization parameters ... */);

        this.state.start('Menu');
        // this.state.start('Game');
    }

    // --------------------------------------------------------------------------

    loadAssets() {
        this.load.pack('game', null, assets);
        this.load.pack('menu', null, assets);
    }

    showSplashScreen() {
        this.add.image(80, 60, 'splash-screen');
        this.load.setPreloadSprite(
            this.add.image(162, 342, 'progress-bar'));
    }

}
