preMenu_boot.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /******************************
  2. * This file holds game states.
  3. ******************************/
  4. /** [BOOT STATE] First state called. Loads media. <br>
  5. *
  6. * @namespace
  7. */
  8. const bootState = {
  9. /**
  10. * Preloads media for current state
  11. */
  12. preload: function () {
  13. // FOR MOODLE
  14. if (moodle) {
  15. loadLangState.firstTime = false;
  16. const moodleLang = iLMparameters.lang;
  17. switch (moodleLang) {
  18. case 'en':
  19. langString = 'en_US';
  20. break;
  21. case 'pt':
  22. langString = 'pt_BR';
  23. break;
  24. case 'fr':
  25. langString = 'fr_FR';
  26. break;
  27. case 'es':
  28. langString = 'es_PE';
  29. break;
  30. case 'it':
  31. langString = 'it_IT';
  32. break;
  33. default:
  34. langString = 'en_US';
  35. }
  36. game.load.lang('./assets/lang/' + langString);
  37. }
  38. // LOADING MEDIA
  39. if (isDebugMode) {
  40. console.log(url.boot.audio.length + ' audio files to cache');
  41. console.log(url.boot.image.length + ' images to cache');
  42. console.log(url.boot.sprite.length + ' sprites to cache');
  43. }
  44. game.load.audio(url.boot.audio);
  45. game.load.image(url.boot.image);
  46. game.load.sprite(url.boot.sprite);
  47. },
  48. /**
  49. * Main code
  50. */
  51. create: function () {
  52. // Calls first screen seen by the player
  53. // FOR MOODLE
  54. if (moodle) {
  55. game.state.start('menu');
  56. } else {
  57. game.state.start('lang');
  58. }
  59. },
  60. };