{"size": 1292, "ext": "js", "max_stars_repo_path": "src/scenes/TitleScene.js", "max_stars_repo_name": "goblineer/goblineer", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/scenes/TitleScene.js", "max_issues_repo_name": "goblineer/goblineer", "max_issues_repo_issues_event_min_datetime": "2021-05-10T04:40:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T15:57:44.000Z", "max_forks_repo_path": "src/scenes/TitleScene.js", "max_forks_repo_name": "goblineer/goblineer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 21.5333333333, "max_line_length": 72, "alphanum_fraction": 0.6044891641}
import 'phaser';

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

  create() {
    this.createTitle();
    this.createPlayButton();
  }

  createTitle() {
    this.titleImage = this.add.image(100, 100, 'title');
    this.centerObject(this.titleImage, 0.5);
  }

  createPlayButton() {
    this.gameButton = this.add.sprite(0, 0, 'button1').setInteractive();
    this.centerObject(this.gameButton, -2.5);
    this.gameButton.setScale(2);

    this.gameText = this.add.text(0, 0, 'Play', {
      fontSize: '32px',
      fill: '#000'
    });

    Phaser.Display.Align.In.Center(this.gameText, this.gameButton);

    this.gameButton.on(
      'pointerdown',
      function(pointer) {
        this.scene.start('Game');
      }.bind(this)
    );

    this.gameButton.on(
      'pointerover',
      function(pointer) {
        this.gameButton.setTexture('button2');
      }.bind(this)
    );

    this.gameButton.on(
      'pointerout',
      function(pointer) {
        this.gameButton.setTexture('button1');
      }.bind(this)
    );
  }

  centerObject(gameObject, offset = 0) {
    var width = this.cameras.main.width;
    var height = this.cameras.main.height;

    gameObject.x = width / 2;
    gameObject.y = height / 2 - offset * 100;
  }
}
