{"size": 1729, "ext": "js", "max_stars_repo_path": "examples/Text/text_041_bitmaptext_with_physics_updating.js", "max_stars_repo_name": "fetaoily/phaser2-game-examples", "max_stars_repo_stars_event_min_datetime": "2018-02-05T13:28:29.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-05T13:28:29.000Z", "max_issues_repo_path": "examples/Text/text_041_bitmaptext_with_physics_updating.js", "max_issues_repo_name": "fetaoily/phaser-game-examples", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/Text/text_041_bitmaptext_with_physics_updating.js", "max_forks_repo_name": "fetaoily/phaser-game-examples", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.8166666667, "max_line_length": 133, "alphanum_fraction": 0.6032388664}
(() => {
  let game;
  let words = ['Ouch!', 'bump', 'eek', 'look out', 'careful', 'mind out', 'watch it!', 'OI!', 'Owww', 'Grrrr', 'that hurt', 'bully'];

  window.onload = () => {
    game = new NewGame();
  };

  class NewGame extends Phaser.Game {
    constructor () {
      super(800, 600, Phaser.AUTO);
      this.state.add('PlayGame', PlayGame);
      this.state.start('PlayGame');
    }
  }

  class PlayGame extends Phaser.State {
    constructor () {
      super();
    }

    preload () {
      this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
      this.scale.pageAlignHorizontally = true;
      this.scale.pageAlignVertically = true;
      //
      this.load.bitmapFont('desyrel', '/assets/fonts/bitmapFonts/desyrel.png', '/assets/fonts/bitmapFonts/desyrel.xml');
      this.load.bitmapFont('stack', '/assets/fonts/bitmapFonts/shortStack.png', '/assets/fonts/bitmapFonts/shortStack.xml');
    }

    create () {
      this.physics.startSystem(Phaser.Physics.ARCADE);
      //
      this.text1 = this.add.bitmapText(200, 100, 'desyrel', 'BitmapText', 64);
      this.text2 = this.add.bitmapText(400, 400, 'stack', 'with Physics', 32);
      //
      this.physics.arcade.enable([this.text1, this.text2]);
      //
      this.text1.body.velocity.setTo(200, 200);
      this.text1.body.collideWorldBounds = true;
      this.text1.body.bounce.set(1);
      //
      this.text2.body.velocity.setTo(-100, -100);
      this.text2.body.collideWorldBounds = true;
      this.text2.body.bounce.set(1);

    }

    update () {
      this.physics.arcade.collide(this.text1, this.text2, this.onCollide, null, this);
    }

    render () {
    }

    onCollide () {
      this.text1.text = this.rnd.pick(words);
    }
  }
})();