{"size": 1895, "ext": "js", "max_stars_repo_path": "src/Scenes/TitleScene.js", "max_stars_repo_name": "tigamadou/shooterGame", "max_stars_repo_stars_event_min_datetime": "2021-04-25T00:22:33.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-25T00:22:33.000Z", "max_issues_repo_path": "src/Scenes/TitleScene.js", "max_issues_repo_name": "tigamadou/shooterGame", "max_issues_repo_issues_event_min_datetime": "2021-03-26T07:57:50.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-31T02:51:12.000Z", "max_forks_repo_path": "src/Scenes/TitleScene.js", "max_forks_repo_name": "tigamadou/shooterGame", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 36.4423076923, "max_line_length": 166, "alphanum_fraction": 0.653298153}
// eslint-disable-next-line import/no-unresolved
import Phaser from 'phaser';
import Button from '../Components/Button';
import Player from '../Components/Player';
import ScrollingBackground from '../Components/ScrollingBackground';

export default class TitleScene extends Phaser.Scene {
  constructor() {
    super('Title');
  }

  preload() {
    this.APP = this.game.APP;
  }

  create() {
    this.game.sound.stopAll();
    this.backgrounds = [];
    for (let i = 0; i < 5; i += 1) { // create five scrolling backgrounds
      const bg = new ScrollingBackground(this, 'sprBg0', i * 10);
      this.backgrounds.push(bg);
    }
    this.globals = this.sys.game.globals;
    this.text = this.add.text(this.game.config.width * 0.5, 100, this.APP.NAME, { fontSize: 40, fontWeight: 'bold' });
    this.text.setOrigin(0.5);
    // Game
    this.gameButton = new Button(this, this.game.config.width * 0.5, this.game.config.height - 150, 'blueButton1', 'blueButton2', 'START', 'Registration');

    // Options
    this.optionsButton = new Button(this, this.game.config.width * 0.5 - 160, this.game.config.height - 80, 'blueButton1', 'blueButton2', 'Options', 'Options');

    // // Leaderboard
    this.leaderBoardButton = new Button(this, this.game.config.width * 0.5, this.game.config.height - 80, 'blueButton1', 'blueButton2', 'LeaderBoard', 'LeaderBoard');

    // // Credits
    this.creditsButton = new Button(this, this.game.config.width * 0.5 + 160, this.game.config.height - 80, 'blueButton1', 'blueButton2', 'Credits', 'Credits');

    if (this.APP.model.musicOn === true) {
      this.globals.bgMusic = this.globals.sfx.music.title;
      this.globals.bgMusic.play();
      this.APP.model.bgMusicPlaying = true;
    }
    this.player = new Player(
      this,
      this.game.config.width * 0.5,
      this.game.config.height * 0.5,
      'sprPlayer',
      this.APP.player,
    );
  }
}
