preloader.js 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. (function() {
  2. 'use strict';
  3. function Preloader() {
  4. this.asset = null;
  5. this.ready = false;
  6. }
  7. Preloader.prototype = {
  8. preload: function () {
  9. this.asset = this.add.sprite(320, 240, 'preloader');
  10. this.asset.anchor.setTo(0.5, 0.5);
  11. this.load.onLoadComplete.addOnce(this.onLoadComplete, this);
  12. this.load.setPreloadSprite(this.asset);
  13. this.load.image('player', 'assets/player.png');
  14. this.load.bitmapFont('minecraftia', 'assets/minecraftia.png', 'assets/minecraftia.xml');
  15. },
  16. create: function () {
  17. this.asset.cropEnabled = false;
  18. },
  19. update: function () {
  20. if (!!this.ready) {
  21. this.game.state.start('menu');
  22. }
  23. },
  24. onLoadComplete: function () {
  25. this.ready = true;
  26. }
  27. };
  28. window['trexrunner'] = window['trexrunner'] || {};
  29. window['trexrunner'].Preloader = Preloader;
  30. }());