123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- const langState = {
-
- create: function () {
- renderBackground('plain');
-
- this.listOfFlags = [];
- this.langs = {
- text: [
- 'PORTUGUÊS ',
- 'ESPAÑOL ',
- 'FRANÇAIS ',
- 'ENGLISH ',
- 'ITALIANO ',
- ],
- flag: ['flag_BR', 'flag_ES', 'flag_FR', 'flag_US', 'flag_IT'],
- lang: ['pt_BR', 'es_ES', 'fr_FR', 'en_US', 'it_IT'],
- x: [-350, -350, -350, 250, 250],
- y: [-220, 0, 220, -110, 110],
- };
-
- for (let i in this.langs.flag) {
-
- game.add.text(
- context.canvas.width / 2 + this.langs.x[i],
- context.canvas.height / 2 + this.langs.y[i],
- this.langs.text[i],
- { ...textStyles.h2_, fill: colors.green }
- ).align = 'right';
-
- const flag = game.add.image(
- context.canvas.width / 2 + this.langs.x[i] + 100,
- context.canvas.height / 2 + this.langs.y[i] - 13,
- this.langs.flag[i]
- );
- flag.anchor(0.5, 0.5);
- this.listOfFlags.push(flag);
- }
- game.event.add('click', this.onInputDown);
- game.event.add('mousemove', this.onInputOver);
- if (isDebugMode && debugState.lang.skip) {
-
- this.setLang(debugState.lang.lang || 'pt_BR');
- }
- },
-
- setLang: function (selectedLang) {
-
- langString = selectedLang;
- if (audioStatus) game.audio.popSound.play();
-
- game.state.start('loadLang');
- },
-
- onInputDown: function (mouseEvent) {
- const x = game.math.getMouse(mouseEvent).x;
- const y = game.math.getMouse(mouseEvent).y;
- self.listOfFlags.forEach((cur) => {
- if (game.math.isOverIcon(x, y, cur)) {
- for (let i in self.langs.flag) {
- if (self.langs.flag[i] == cur.name) {
- self.setLang(self.langs.lang[i]);
- break;
- }
- }
- }
- });
- },
-
- onInputOver: function (mouseEvent) {
- const x = game.math.getMouse(mouseEvent).x;
- const y = game.math.getMouse(mouseEvent).y;
- let flag = false;
- self.listOfFlags.forEach((cur) => {
- if (game.math.isOverIcon(x, y, cur)) {
- flag = true;
- cur.scale = cur.scale = 1.05;
- } else {
- cur.scale = cur.scale = 1;
- }
- });
- if (flag) document.body.style.cursor = 'pointer';
- else document.body.style.cursor = 'auto';
- game.render.all();
- },
- };
- const loadLangState = {
-
- preload: function () {
-
- game.load.lang('./assets/lang/' + langString);
- },
-
- create: function () {
- if (isDebugMode) console.log('Language: ' + langString);
-
- if (this.firstTime == undefined) {
- this.firstTime = false;
- game.state.start('name');
- } else {
- game.state.start('menu');
- }
- },
- };
|