Création d'un bouton pour couper le son - Résolution d'un crash lors de la mort de notre cible - Réduction de la police dans certaine zone - Réduction du code en double lors de la création d'une action - Modification de la création des scènes dans le but d'implémenter la langue sur chaque scène importante - Chaque scène importante a comme père ManageLang qui permet la création des drapeaux en haut à droite de la scène dans le but de changer la langue - Lors du changement de langue, on crée la scène LoadFile dans le but de recharger les fichiers avec la bonne langue, puis on rechargche la scène actuelle - Cette manière de fonctionner a un problème, ça recréé la scène ce qui a pour finition de recharger le jeux à 0 (donc si on change de langue après avoir commencé à jouer, ça va recharger le jeux à 0) - Gestion de la touche "echap" dans le but de supprimer l'action sélectionnée (poubelle) - Meilleur gestion des mise à jour de frame, le jeux devraient moins utiliser de ressources quand il ne se passe rien à l'écran. (Avant il recalculait les lignes entre les actions à chaque frame) - Réslution d'un problème lorsqu'on mettait plus de deux conditions à la suite (les actions après ces deux conditions ne s'effectuaient pas dans le bon ordre) - Modification de la manière de trier les actions
parent
f2ec732f68
commit
c744f783cd
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
@ -1 +1 @@
|
||||
function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}function newGame(e){-1!==e.scene.getIndex("Game")&&e.scene.remove("Game"),e.scene.add("Game",new Game(e))}function chooseTarget(e,t){let n=2*WIDTH_MAP,a=[];return t.forEach(function(t){if(t!==e){let o=Math.hypot(t.x-e.x,t.y-e.y);n>=o&&(n>o&&(n=o,a=[]),a.push(t))}}),a.length>1?a[Math.floor(Math.random()*(a.length+1))]:a[0]}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase(),SPEED_GAME=1;const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2,HEIGHT_BONUS=WIDTH_MAP/10,HEIGHT_DAMAGE=WIDTH_MAP/20,DURATION_DAMAGE=700;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"};let father=new Phaser.Game(config);father.scene.add("Boot",new Boot(father)),father.scene.start("Boot");
|
||||
function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}function newGame(e){-1!==e.scene.getIndex("Game")&&e.scene.remove("Game"),e.scene.add("Game",new Game(e))}function chooseTarget(e,t){let a=2*WIDTH_MAP,n=[];return t.forEach(function(t){if(t!==e){let o=Math.hypot(t.x-e.x,t.y-e.y);a>=o&&(a>o&&(a=o,n=[]),n.push(t))}}),n.length>1?n[Math.floor(Math.random()*(n.length+1))]:n[0]}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase(),SPEED_GAME=1;const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2,HEIGHT_BONUS=WIDTH_MAP/10,HEIGHT_DAMAGE=WIDTH_MAP/20,DURATION_DAMAGE=700;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"};let father=new Phaser.Game(config);father.scene.add("LoadFile",new LoadFile(father,"Boot",new Boot(father))),father.scene.start("LoadFile");
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
class AddNode extends Phaser.Scene{constructor(e,t,s){super("AddNode"),this.father=e,this.gameR=t,this.selected=s,this.lCategory=[]}create(e){let t=HEIGHT_WINDOW/(4/3);this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,t,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(e)}addButton(e,t,s,i,n,r=new Category,a){let o=this.createButton(e,t,s,i,n);return o.on("pointerdown",()=>this.click(o,r,a)),o}createButton(e,t,s,i,n){let r=this.add.image(e,t,n).setOrigin(.5,.5).setInteractive();return r.on("pointerover",()=>r.setFrame(1)),r.on("pointerout",()=>r.setFrame(0)),r.displayHeight=i,null===s?r.scaleX=r.scaleY:r.displayWidth=s,r}click(e,t,s){e.isTinted?t.remove(e):t.add(e,s)}newCategory(e,t,s){let i=new Category(e,t,s);return this.lCategory.push(i),i}addTitle(e,t,s){let i={font:(HEIGHT_WINDOW/12).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(e,t,s,i).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"cancel").on("pointerdown",()=>this.cancel())}createButtonAdd(e){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"add").on("pointerdown",()=>e.addNode())}verifyCategory(){for(let e=0;e<this.lCategory.length;e++)if(!this.lCategory[e].validate())return!1;return!0}cancel(){this.scene.resume("Game"),this.scene.stop("AddNode"),this.father.scene.remove("AddNode")}}class Bonus extends Phaser.GameObjects.Image{constructor(e,t,s,i,n,r){super(t,s,i,n),this.setOrigin(.5,.5),this.displayHeight=HEIGHT_BONUS,this.scaleX=this.scaleY,t.add.existing(this),this.name=e,this.value=r,this.scene=t}}class Finish extends Phaser.Scene{constructor(e){super("Finish"),this.father=e}create(){this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,HEIGHT_WINDOW/2,3487290).setOrigin(0,.5)}addTitle(e){let t={font:(HEIGHT_WINDOW/6).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,e,t).setOrigin(.5,.5)}createButton(e,t){let s=this.add.image(e,HEIGHT_WINDOW/8*7,t).setOrigin(.5,.5).setInteractive();return s.on("pointerover",()=>s.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.displayHeight=HEIGHT_WINDOW/9,s.scaleX=s.scaleY,s}btnRetry(e){e.on("pointerdown",()=>this.retry())}retry(){console.log("RETRY"),this.close(),newGame(this.father),this.father.scene.start("Game")}btnHome(e){e.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.start("Type")}btnNext(e){e.on("pointerdown",()=>this.next())}next(){console.log("NEXT")}close(){this.sound.stopAll(),this.father.scene.remove("GamingBoard"),this.father.scene.remove("Game"),this.father.scene.remove("Finish")}}
|
||||
class AddNode extends Phaser.Scene{constructor(e,t,s){super("AddNode"),this.father=e,this.gameR=t,this.selected=s,this.lCategory=[];let i=HEIGHT_WINDOW/14;this.style={font:i.toString()+"px stencil",fill:"#e2e2e2"},this.heightButton=HEIGHT_WINDOW/8}create(e){let t=HEIGHT_WINDOW/(4/3);this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,t,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(e)}addButton(e,t,s,i=new Category,a){let n=this.createButton(e,t,s);return n.on("pointerdown",()=>this.click(n,i,a)),n}createButton(e,t,s,i=this.heightButton,a=null){let n=this.add.image(e,t,s).setOrigin(.5,.5).setInteractive();return n.on("pointerover",()=>n.setFrame(1)),n.on("pointerout",()=>n.setFrame(0)),n.displayHeight=i,null===a?n.scaleX=n.scaleY:n.displayWidth=a,n}click(e,t,s){e.isTinted?t.remove(e):t.add(e,s)}newCategory(e,t,s){let i=new Category(e,t,s);return this.lCategory.push(i),i}addTitle(e,t,s){this.add.text(e,t,s,this.style).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),"cancel",HEIGHT_WINDOW/9).on("pointerdown",()=>this.cancel())}createButtonAdd(e){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),"add",HEIGHT_WINDOW/9).on("pointerdown",()=>e.addNode())}verifyCategory(){for(let e=0;e<this.lCategory.length;e++)if(!this.lCategory[e].validate())return!1;return!0}cancel(){this.scene.resume("Game"),this.scene.stop("AddNode"),this.father.scene.remove("AddNode")}}class Bonus extends Phaser.GameObjects.Image{constructor(e,t,s,i,a,n){super(t,s,i,a),this.setOrigin(.5,.5),this.displayHeight=HEIGHT_BONUS,this.scaleX=this.scaleY,t.add.existing(this),this.name=e,this.value=n,this.scene=t}}class Finish extends Phaser.Scene{constructor(e){super("Finish"),this.father=e}create(){this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,HEIGHT_WINDOW/2,3487290).setOrigin(0,.5)}addTitle(e){let t={font:(HEIGHT_WINDOW/6).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,e,t).setOrigin(.5,.5)}createButton(e,t){let s=this.add.image(e,HEIGHT_WINDOW/8*7,t).setOrigin(.5,.5).setInteractive();return s.on("pointerover",()=>s.setFrame(1)),s.on("pointerout",()=>s.setFrame(0)),s.displayHeight=HEIGHT_WINDOW/9,s.scaleX=s.scaleY,s}btnRetry(e){e.on("pointerdown",()=>this.retry())}retry(){console.log("RETRY"),this.close(),newGame(this.father),this.father.scene.start("Game")}btnHome(e){e.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.start("Type")}btnNext(e){e.on("pointerdown",()=>this.next())}next(){console.log("NEXT")}close(){this.sound.stopAll(),this.father.scene.remove("GamingBoard"),this.father.scene.remove("Game"),this.father.scene.remove("Finish")}}class ManageLang extends Phaser.Scene{constructor(e,t){super(e),this.name=e,this.father=t,this.otherScenes=[]}addOtherScenes(e){this.otherScenes.push(e)}create(){this.createFlags()}createFlags(){this.diffXFlag=0,this.createFlag("fr"),this.createFlag("en")}createFlag(e){let t=this.add.image(WIDTH_WINDOW-10-this.diffXFlag,10,e).setOrigin(1,0).setInteractive();t.displayHeight=40,t.scaleX=t.scaleY,this.diffXFlag=this.diffXFlag+t.displayWidth+10,t.on("pointerdown",()=>this.setLang(e))}setLang(e){e!==LANG&&(LANG=e,this.father.scene.add("LoadFile",new LoadFile(this.father,this.name)),this.father.scene.start("LoadFile"),this.otherScenes.forEach(e=>this.father.scene.stop(e)))}}
|
@ -1,157 +1,22 @@
|
||||
class Boot extends Phaser.Scene {
|
||||
class Boot extends ManageLang {
|
||||
constructor(father) {
|
||||
super('Boot');
|
||||
this.father = father;
|
||||
}
|
||||
|
||||
preload() {
|
||||
let progressBar = this.add.graphics();
|
||||
let progressBox = this.add.graphics();
|
||||
let width = 320;
|
||||
let height = 50;
|
||||
let x = WIDTH_WINDOW / 2 - width / 2;
|
||||
let y = HEIGHT_WINDOW / 2 - height / 2;
|
||||
|
||||
progressBox.fillStyle(0x222222, 0.8);
|
||||
progressBox.fillRect(x, y, 320, height);
|
||||
this.load.on('progress', function (value) {
|
||||
progressBar.clear();
|
||||
progressBar.fillStyle(0xffffff, 1);
|
||||
progressBar.fillRect(x + 10, y + 10, (width - 20) * value, height - 20);
|
||||
});
|
||||
this.load.on('complete', function () {
|
||||
progressBar.destroy();
|
||||
progressBox.destroy();
|
||||
});
|
||||
|
||||
this.load.audio('shot', 'assets/sounds/shot.ogg');
|
||||
this.load.audio('hit', 'assets/sounds/hit.ogg');
|
||||
|
||||
this.loadImage('en', 'flags/', true);
|
||||
this.loadImage('fr', 'flags/', true);
|
||||
|
||||
this.loadImage('bonusSpeed0', 'bonus/', true);
|
||||
this.loadImage('bonusSpeed1', 'bonus/', true);
|
||||
this.loadImage('bonusSpeed2', 'bonus/', true);
|
||||
|
||||
this.loadSprite('playLetter', 550, 150, 'buttons/');
|
||||
this.loadSprite('cancel', 550, 150, 'buttons/');
|
||||
this.loadSprite('add', 550, 150, 'buttons/');
|
||||
this.loadSprite('home', 550, 150, 'buttons/');
|
||||
this.loadSprite('next', 550, 150, 'buttons/');
|
||||
this.loadSprite('retry', 550, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('duel', 269, 262, 'buttons/');
|
||||
this.loadSprite('last', 269, 262, 'buttons/');
|
||||
this.loadSprite('team', 269, 262, 'buttons/');
|
||||
this.loadSprite('flag', 269, 262, 'buttons/');
|
||||
this.loadSprite('map', 269, 262, 'buttons/');
|
||||
|
||||
this.loadSprite('play', 100, 100, 'buttons/');
|
||||
this.loadSprite('bin', 100, 100, 'buttons/');
|
||||
this.loadSprite('plus', 100, 100, 'buttons/');
|
||||
this.loadSprite('pencil', 100, 100, 'buttons/');
|
||||
this.loadSprite('speed', 100, 100, 'buttons/');
|
||||
this.loadSprite('back', 200, 200, 'buttons/');
|
||||
|
||||
this.loadSprite('shortRange', 300, 150, 'buttons/');
|
||||
this.loadSprite('mediumRange', 300, 150, 'buttons/');
|
||||
this.loadSprite('longRange', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('shield0', 300, 150, 'buttons/');
|
||||
this.loadSprite('shield33', 300, 150, 'buttons/');
|
||||
this.loadSprite('shield66', 300, 150, 'buttons/');
|
||||
this.loadSprite('shield100', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('myself', 300, 150, 'buttons/');
|
||||
this.loadSprite('enemyBot', 300, 150, 'buttons/');
|
||||
this.loadSprite('bonus', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('moveToward', 300, 150, 'buttons/');
|
||||
this.loadSprite('fleeFrom', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('attackNode', 180, 190, 'nodes/', true);
|
||||
this.loadSprite('moveNode', 180, 190, 'nodes/', true);
|
||||
this.loadSprite('conditionNode', 180, 190, 'nodes/', true);
|
||||
|
||||
|
||||
this.loadImage('background');
|
||||
this.loadImage('bullet');
|
||||
this.loadImage('logoWaria');
|
||||
this.loadImage('attack', 'nodes/', true);
|
||||
this.loadImage('move', 'nodes/', true);
|
||||
this.loadImage('condition', 'nodes/', true);
|
||||
super('Boot', father);
|
||||
}
|
||||
|
||||
create() {
|
||||
super.create();
|
||||
let style = {font: '200px stencil', fill: "#e2e2e2"};
|
||||
this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 3, "WARIA", style).setOrigin(0.5, 0.5);
|
||||
let btn = this.add.sprite(WIDTH_WINDOW / 2, (HEIGHT_WINDOW / 3) * 2, 'playLetter').setInteractive();
|
||||
//btn.setFrame(0);
|
||||
btn.on('pointerout', () => btn.setFrame(0));
|
||||
btn.on('pointerover', () => btn.setFrame(1));
|
||||
btn.on('pointerdown', () => this.clickPlay(btn));
|
||||
|
||||
this.createFlags();
|
||||
}
|
||||
|
||||
createFlags() {
|
||||
this.diffXFlag = 0;
|
||||
this.createFlag('fr');
|
||||
this.createFlag('en');
|
||||
}
|
||||
|
||||
createFlag(name) {
|
||||
let flag = this.add.image(WIDTH_WINDOW - 10 - this.diffXFlag, 10, name).setOrigin(1, 0).setInteractive();
|
||||
flag.displayHeight = 40;
|
||||
flag.scaleX = flag.scaleY;
|
||||
this.diffXFlag = this.diffXFlag + flag.displayWidth + 10;
|
||||
flag.on('pointerdown', () => this.setLang(name));
|
||||
}
|
||||
|
||||
setLang(lang) {
|
||||
if (lang !== LANG) {
|
||||
LANG = lang;
|
||||
console.log('Set Lang : ' + lang);
|
||||
|
||||
this.scene.restart();
|
||||
}
|
||||
}
|
||||
|
||||
clickPlay(btn) {
|
||||
btn.setFrame(2);
|
||||
console.log("Play");
|
||||
this.father.scene.add('Type', new Type(this.father));
|
||||
this.scene.start('Type');
|
||||
}
|
||||
|
||||
loadSprite(name, width, height, folder = '', force = false) {
|
||||
this.deleteLoad(name);
|
||||
if (force) {
|
||||
this.load.spritesheet(name, 'assets/' + folder + name + '.png', {
|
||||
frameWidth: width,
|
||||
frameHeight: height
|
||||
});
|
||||
} else {
|
||||
this.load.spritesheet(name, 'assets/' + LANG + '/' + folder + name + '.png', {
|
||||
frameWidth: width,
|
||||
frameHeight: height
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadImage(name, folder = '', force = false) {
|
||||
this.deleteLoad(name);
|
||||
if (force) {
|
||||
this.load.image(name, 'assets/' + folder + name + '.png');
|
||||
} else {
|
||||
this.load.image(name, 'assets/' + LANG + '/' + folder + name + '.png');
|
||||
}
|
||||
}
|
||||
|
||||
deleteLoad(name) {
|
||||
if (this.textures.exists(name)) {
|
||||
this.textures.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
class LoadFile extends Phaser.Scene {
|
||||
constructor(father, nameSon, son) {
|
||||
super('LoadFile');
|
||||
this.father = father;
|
||||
this.son = son;
|
||||
this.nameSon = nameSon;
|
||||
|
||||
this.father.scene.pause(this.nameSon);
|
||||
this.father.scene.stop(this.nameSon);
|
||||
this.father.scene.remove('LoadFile');
|
||||
}
|
||||
|
||||
preload() {
|
||||
let progressBar = this.add.graphics();
|
||||
let progressBox = this.add.graphics();
|
||||
let width = 320;
|
||||
let height = 50;
|
||||
let x = WIDTH_WINDOW / 2 - width / 2;
|
||||
let y = HEIGHT_WINDOW / 2 - height / 2;
|
||||
|
||||
progressBox.fillStyle(0x222222, 0.8);
|
||||
progressBox.fillRect(x, y, 320, height);
|
||||
this.load.on('progress', function (value) {
|
||||
progressBar.clear();
|
||||
progressBar.fillStyle(0xffffff, 1);
|
||||
progressBar.fillRect(x + 10, y + 10, (width - 20) * value, height - 20);
|
||||
});
|
||||
this.load.on('complete', () => {
|
||||
|
||||
progressBar.destroy();
|
||||
progressBox.destroy();
|
||||
if (this.father.scene.getIndex(this.nameSon) === -1) {
|
||||
this.father.scene.add(this.nameSon, this.son);
|
||||
}
|
||||
this.father.scene.start(this.nameSon);
|
||||
});
|
||||
|
||||
this.load.audio('shot', 'assets/sounds/shot.ogg');
|
||||
this.load.audio('hit', 'assets/sounds/hit.ogg');
|
||||
|
||||
this.loadImage('en', 'flags/', true);
|
||||
this.loadImage('fr', 'flags/', true);
|
||||
|
||||
this.loadImage('bonusSpeed0', 'bonus/', true);
|
||||
this.loadImage('bonusSpeed1', 'bonus/', true);
|
||||
this.loadImage('bonusSpeed2', 'bonus/', true);
|
||||
|
||||
this.loadSprite('playLetter', 550, 150, 'buttons/');
|
||||
this.loadSprite('cancel', 550, 150, 'buttons/');
|
||||
this.loadSprite('add', 550, 150, 'buttons/');
|
||||
this.loadSprite('home', 550, 150, 'buttons/');
|
||||
this.loadSprite('next', 550, 150, 'buttons/');
|
||||
this.loadSprite('retry', 550, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('duel', 269, 262, 'buttons/');
|
||||
this.loadSprite('last', 269, 262, 'buttons/');
|
||||
this.loadSprite('team', 269, 262, 'buttons/');
|
||||
this.loadSprite('flag', 269, 262, 'buttons/');
|
||||
this.loadSprite('map', 269, 262, 'buttons/');
|
||||
|
||||
this.loadSprite('play', 100, 100, 'buttons/');
|
||||
this.loadSprite('bin', 100, 100, 'buttons/');
|
||||
this.loadSprite('plus', 100, 100, 'buttons/');
|
||||
this.loadSprite('pencil', 100, 100, 'buttons/');
|
||||
this.loadSprite('speed', 100, 100, 'buttons/');
|
||||
this.loadSprite('mute', 100, 100, 'buttons/');
|
||||
this.loadSprite('back', 200, 200, 'buttons/');
|
||||
|
||||
this.loadSprite('shortRange', 300, 150, 'buttons/');
|
||||
this.loadSprite('mediumRange', 300, 150, 'buttons/');
|
||||
this.loadSprite('longRange', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('shield0', 300, 150, 'buttons/');
|
||||
this.loadSprite('shield33', 300, 150, 'buttons/');
|
||||
this.loadSprite('shield66', 300, 150, 'buttons/');
|
||||
this.loadSprite('shield100', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('myself', 300, 150, 'buttons/');
|
||||
this.loadSprite('enemyBot', 300, 150, 'buttons/');
|
||||
this.loadSprite('bonus', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('moveToward', 300, 150, 'buttons/');
|
||||
this.loadSprite('fleeFrom', 300, 150, 'buttons/');
|
||||
|
||||
this.loadSprite('attackNode', 180, 190, 'nodes/', true);
|
||||
this.loadSprite('moveNode', 180, 190, 'nodes/', true);
|
||||
this.loadSprite('conditionNode', 180, 190, 'nodes/', true);
|
||||
|
||||
|
||||
this.loadImage('background');
|
||||
this.loadImage('bullet');
|
||||
this.loadImage('logoWaria');
|
||||
this.loadImage('attack', 'nodes/', true);
|
||||
this.loadImage('move', 'nodes/', true);
|
||||
this.loadImage('condition', 'nodes/', true);
|
||||
}
|
||||
|
||||
loadSprite(name, width, height, folder = '', force = false) {
|
||||
this.deleteLoad(name);
|
||||
if (force) {
|
||||
this.load.spritesheet(name, 'assets/' + folder + name + '.png', {
|
||||
frameWidth: width,
|
||||
frameHeight: height
|
||||
});
|
||||
} else {
|
||||
this.load.spritesheet(name, 'assets/' + LANG + '/' + folder + name + '.png', {
|
||||
frameWidth: width,
|
||||
frameHeight: height
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadImage(name, folder = '', force = false) {
|
||||
this.deleteLoad(name);
|
||||
if (force) {
|
||||
this.load.image(name, 'assets/' + folder + name + '.png');
|
||||
} else {
|
||||
this.load.image(name, 'assets/' + LANG + '/' + folder + name + '.png');
|
||||
}
|
||||
}
|
||||
|
||||
deleteLoad(name) {
|
||||
if (this.textures.exists(name)) {
|
||||
this.textures.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
class ManageLang extends Phaser.Scene {
|
||||
constructor(name, father) {
|
||||
super(name);
|
||||
this.name = name;
|
||||
this.father = father;
|
||||
this.otherScenes = [];
|
||||
}
|
||||
|
||||
addOtherScenes(name) {
|
||||
this.otherScenes.push(name);
|
||||
}
|
||||
|
||||
create() {
|
||||
this.createFlags();
|
||||
}
|
||||
|
||||
createFlags() {
|
||||
this.diffXFlag = 0;
|
||||
this.createFlag('fr');
|
||||
this.createFlag('en');
|
||||
}
|
||||
|
||||
createFlag(name) {
|
||||
let flag = this.add.image(WIDTH_WINDOW - 10 - this.diffXFlag, 10, name).setOrigin(1, 0).setInteractive();
|
||||
flag.displayHeight = 40;
|
||||
flag.scaleX = flag.scaleY;
|
||||
this.diffXFlag = this.diffXFlag + flag.displayWidth + 10;
|
||||
flag.on('pointerdown', () => this.setLang(name));
|
||||
}
|
||||
|
||||
setLang(lang) {
|
||||
if (lang !== LANG) {
|
||||
LANG = lang;
|
||||
this.father.scene.add('LoadFile', new LoadFile(this.father, this.name));
|
||||
this.father.scene.start('LoadFile');
|
||||
this.otherScenes.forEach(scene => this.father.scene.stop(scene));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue