main.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. 'use strict';
  2. /* eslint-disable no-unused-vars */
  3. /* eslint-disable no-console */
  4. import PhaserEngine from './controller/phaser-engine';
  5. function startGame() {
  6. console.log('start Game');
  7. let phaserEngine = new PhaserEngine();
  8. phaserEngine.start();
  9. }
  10. let app = {
  11. // Application Constructor
  12. initialize: function () {
  13. console.log('app initialize');
  14. document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
  15. },
  16. // deviceready Event Handler
  17. //
  18. // Bind any cordova events here. Common events are:
  19. // 'pause', 'resume', etc.
  20. onDeviceReady: function () {
  21. this.receivedEvent('deviceready');
  22. startGame();
  23. },
  24. // Update DOM on a Received Event
  25. receivedEvent: function (id) {
  26. var parentElement = document.getElementById(id);
  27. var listeningElement = parentElement.querySelector('.listening');
  28. var receivedElement = parentElement.querySelector('.received');
  29. listeningElement.setAttribute('style', 'display:none;');
  30. receivedElement.setAttribute('style', 'display:block;');
  31. console.log('Received Event: ' + id);
  32. }
  33. };
  34. console.log('cordova :', process.env.CORDOVA );
  35. if (process.env.CORDOVA) {
  36. app.initialize();
  37. } else {
  38. startGame();
  39. }
  40. // const config = {
  41. // type: Phaser.AUTO,
  42. // parent: "phaser-example",
  43. // width: 800,
  44. // height: 600,
  45. // scene: {
  46. // preload: preload,
  47. // create: create
  48. // }
  49. // };
  50. // const game = new Phaser.Game(config);
  51. // function preload() {
  52. // this.load.image("logo", logoImg);
  53. // }
  54. // function create() {
  55. // const logo = this.add.image(400, 150, "logo");
  56. // this.tweens.add({
  57. // targets: logo,
  58. // y: 350,
  59. // duration: 2000,
  60. // ease: "Power2",
  61. // yoyo: true,
  62. // loop: -1
  63. // });
  64. // }