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

master
clmaisonha 5 years ago
parent f2ec732f68
commit c744f783cd

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

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)))}}

@ -67,6 +67,5 @@ var config = {
}; };
let father = new Phaser.Game(config); let father = new Phaser.Game(config);
father.scene.add('LoadFile', new LoadFile(father, 'Boot', new Boot(father)));
father.scene.add('Boot', new Boot(father)); father.scene.start('LoadFile');
father.scene.start('Boot');

@ -10,11 +10,11 @@ class AddAttack extends AddNode {
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?")); super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS (OPTIONAL)", "FILTRES CIBLES (FACULTATIF)")); super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS (OPTIONAL)", "FILTRES CIBLES (FACULTATIF)"));
super.addButton(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot', super.newCategory('target', true, true), false); super.addButton(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 5), 'enemyBot', super.newCategory('target', true, true), false);
let c2 = super.newCategory('range', true, true); let c2 = super.newCategory('range', true, true);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), null, HEIGHT_WINDOW / 8, 'shortRange', c2, 1 / 3); super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), 'shortRange', c2, 1 / 3);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), null, HEIGHT_WINDOW / 8, 'mediumRange', c2, 2 / 3); super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), 'mediumRange', c2, 2 / 3);
super.addButton(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 12), null, HEIGHT_WINDOW / 8, 'longRange', c2, 1); super.addButton(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 12), 'longRange', c2, 1);
} }
addNode() { addNode() {

@ -10,13 +10,13 @@ class AddCondition extends AddNode {
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?")); super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS (OPTIONAL)", "FILTRES CIBLES (FACULTATIF)")); super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / (16 / 7), selectWord("TARGET FILTERS (OPTIONAL)", "FILTRES CIBLES (FACULTATIF)"));
let c1 = super.newCategory('target', true, true); let c1 = super.newCategory('target', true, true);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot', c1, false); super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), 'enemyBot', c1, false);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'myself', c1, true); super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 5), 'myself', c1, true);
let c2 = super.newCategory('shield', true, true); let c2 = super.newCategory('shield', true, true);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), null, HEIGHT_WINDOW / 8, 'shield0', c2, 0); super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 9), 'shield0', c2, 0);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), null, HEIGHT_WINDOW / 8, 'shield33', c2, 1 / 3); super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 9), 'shield33', c2, 1 / 3);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 12), null, HEIGHT_WINDOW / 8, 'shield66', c2, 2 / 3); super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 12), 'shield66', c2, 2 / 3);
super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 12), null, HEIGHT_WINDOW / 8, 'shield100', c2, 1); super.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 12), 'shield100', c2, 1);
} }
addNode() { addNode() {

@ -9,12 +9,12 @@ class AddMove extends AddNode {
super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, selectWord("ADD NODE : MOVE", "AJOUTER ACTION : DEPLACEMENT")); super.addTitle(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 16, selectWord("ADD NODE : MOVE", "AJOUTER ACTION : DEPLACEMENT"));
super.addTitle(WIDTH_WINDOW / 4, HEIGHT_WINDOW / (16 / 3), selectWord("FLEE OR MOVE ?", "RECULER OU AVANCER ?")); super.addTitle(WIDTH_WINDOW / 4, HEIGHT_WINDOW / (16 / 3), selectWord("FLEE OR MOVE ?", "RECULER OU AVANCER ?"));
let c1 = super.newCategory('direction', true, true); let c1 = super.newCategory('direction', true, true);
super.addButton(WIDTH_WINDOW / 6, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'fleeFrom', c1, false); super.addButton(WIDTH_WINDOW / 6, HEIGHT_WINDOW / (16 / 5), 'fleeFrom', c1, false);
super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'moveToward', c1, true); super.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 5), 'moveToward', c1, true);
super.addTitle(WIDTH_WINDOW / 4 * 3, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?")); super.addTitle(WIDTH_WINDOW / 4 * 3, HEIGHT_WINDOW / (16 / 3), selectWord("WHO ?", "QUI ?"));
let c2 = super.newCategory('target', true, true); let c2 = super.newCategory('target', true, true);
super.addButton(WIDTH_WINDOW / 6 * 4, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'enemyBot', c2, true); super.addButton(WIDTH_WINDOW / 6 * 4, HEIGHT_WINDOW / (16 / 5), 'enemyBot', c2, true);
super.addButton(WIDTH_WINDOW / 6 * 5, HEIGHT_WINDOW / (16 / 5), null, HEIGHT_WINDOW / 8, 'bonus', c2, false); super.addButton(WIDTH_WINDOW / 6 * 5, HEIGHT_WINDOW / (16 / 5), 'bonus', c2, false);
} }
addNode() { addNode() {

@ -1,157 +1,22 @@
class Boot extends Phaser.Scene { class Boot extends ManageLang {
constructor(father) { constructor(father) {
super('Boot'); super('Boot', father);
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);
} }
create() { create() {
super.create();
let style = {font: '200px stencil', fill: "#e2e2e2"}; let style = {font: '200px stencil', fill: "#e2e2e2"};
this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 3, "WARIA", style).setOrigin(0.5, 0.5); 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(); 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('pointerout', () => btn.setFrame(0));
btn.on('pointerover', () => btn.setFrame(1)); btn.on('pointerover', () => btn.setFrame(1));
btn.on('pointerdown', () => this.clickPlay(btn)); 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) { clickPlay(btn) {
btn.setFrame(2);
console.log("Play"); console.log("Play");
this.father.scene.add('Type', new Type(this.father)); this.father.scene.add('Type', new Type(this.father));
this.scene.start('Type'); 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);
}
}
} }

@ -1,22 +1,25 @@
class Game extends Phaser.Scene { class Game extends ManageLang {
constructor(father) { constructor(father) {
super('Game'); super('Game', father);
this.father = father; super.addOtherScenes('GamingBoard');
} }
preload() { create() {
super.create();
this.doLine = false;
SPEED_GAME = 1;
this.gm = new GamingBoard(this); this.gm = new GamingBoard(this);
if (this.father.scene.getIndex('GamingBoard') !== -1) {
this.father.scene.remove('GamingBoard');
}
this.father.scene.add('GamingBoard', this.gm); this.father.scene.add('GamingBoard', this.gm);
} this.scene.launch('GamingBoard');
this.scene.pause('GamingBoard');
create() {
this.selected = null; this.selected = null;
this.createButton(); this.createButton();
this.scene.launch('GamingBoard');
this.scene.pause('GamingBoard');
let centerX = WIDTH_WINDOW / 4 * 3; let centerX = WIDTH_WINDOW / 4 * 3;
let diffX = WIDTH_WINDOW / 10; let diffX = WIDTH_WINDOW / 10;
this.tree = new RectangleNode(centerX, HEIGHT_WINDOW / 10, this, 'waria'); this.tree = new RectangleNode(centerX, HEIGHT_WINDOW / 10, this, 'waria');
@ -33,16 +36,21 @@ class Game extends Phaser.Scene {
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, WIDTH_MAP * 0.9, 0x6666ff, this.gm, MYSELF)); this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, WIDTH_MAP * 0.9, 0x6666ff, this.gm, MYSELF));
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.2, WIDTH_MAP * 0.1, 0xff0000, this.gm)); this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.2, WIDTH_MAP * 0.1, 0xff0000, this.gm));
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, 0xff0000, this.gm)); this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, 0xff0000, this.gm));
this.input.keyboard.on('keydown-ESC', () => {
this.clickBin();
});
} }
update(time, delta) { update(time, delta) {
super.update(time, delta); super.update(time, delta);
this.tree.updateLine(); if (this.doLine)
this.tree.updateLine();
} }
finish() { finish() {
console.log("FINISH"); console.log("FINISH");
SPEED_GAME = 1;
let winner; let winner;
if (this.gm.winner()) { if (this.gm.winner()) {
winner = new Winner(this.father); winner = new Winner(this.father);
@ -58,15 +66,10 @@ class Game extends Phaser.Scene {
clickNode() { clickNode() {
this.pencil.setVisible(false); this.tryClick();
this.bin.setVisible(false);
this.plus.setVisible(false);
if (this.selected != null) {
this.selected.deselect();
}
this.selected = this.tree.getSelected(); this.selected = this.tree.getSelected();
if (this.selected == null) if (this.selected === null)
return; return;
if (this.selected !== this.tree) { if (this.selected !== this.tree) {
@ -83,6 +86,19 @@ class Game extends Phaser.Scene {
target.setY(dragY); target.setY(dragY);
} }
dragStart(btn) {
console.log("START DRAG");
this.doLine = true;
this.pauseScene(btn);
}
dragEnd() {
console.log("END DRAG");
this.doLine = false;
}
pauseScene(btn) { pauseScene(btn) {
this.linePlay = 0; this.linePlay = 0;
@ -94,13 +110,8 @@ class Game extends Phaser.Scene {
resume() { resume() {
this.linePlay = 1; this.linePlay = 1;
const sortDesc = (a, b) => a.getX() - b.getX(); let sortDesc = (a, b) => a.getX() - b.getX();
this.tree.lRect.sort(sortDesc); this.tree.sort(sortDesc);
this.tree.lRect.forEach(function (element) {
if (element.lRect !== undefined) {
element.lRect.sort(sortDesc);
}
})
this.gm.modifyNodes(this.tree.getNodes()); this.gm.modifyNodes(this.tree.getNodes());
this.gm.resume(); this.gm.resume();
@ -126,13 +137,21 @@ class Game extends Phaser.Scene {
this.bin = this.add.sprite(x - diffX * 3, y, 'bin').setOrigin(1, 0).setInteractive().setVisible(false); this.bin = this.add.sprite(x - diffX * 3, y, 'bin').setOrigin(1, 0).setInteractive().setVisible(false);
this.plus = this.add.sprite(x - diffX * 4, y, 'plus').setOrigin(1, 0).setInteractive().setVisible(false); this.plus = this.add.sprite(x - diffX * 4, y, 'plus').setOrigin(1, 0).setInteractive().setVisible(false);
let mute = this.add.sprite(x - diffX * 5, y, 'mute').setOrigin(1, 0).setInteractive();
this.linePlay = 0; this.linePlay = 0;
this.lineSpeed = 0; this.lineSpeed = 0;
if (this.father.sound.mute) {
this.lineMute = 1;
} else {
this.lineMute = 0;
}
back.displayHeight = back.displayWidth = width; back.displayHeight = back.displayWidth = width;
play.displayHeight = play.displayWidth = width; play.displayHeight = play.displayWidth = width;
speed.displayHeight = speed.displayWidth = width; speed.displayHeight = speed.displayWidth = width;
mute.displayHeight = mute.displayWidth = width;
this.pencil.displayHeight = this.pencil.displayWidth = width; this.pencil.displayHeight = this.pencil.displayWidth = width;
this.bin.displayHeight = this.bin.displayWidth = width; this.bin.displayHeight = this.bin.displayWidth = width;
this.plus.displayHeight = this.plus.displayWidth = width; this.plus.displayHeight = this.plus.displayWidth = width;
@ -141,6 +160,8 @@ class Game extends Phaser.Scene {
play.on('pointerover', () => this.changeFrame(play, 1, this.linePlay)); play.on('pointerover', () => this.changeFrame(play, 1, this.linePlay));
speed.on('pointerout', () => this.changeFrame(speed, 0, this.lineSpeed)); speed.on('pointerout', () => this.changeFrame(speed, 0, this.lineSpeed));
speed.on('pointerover', () => this.changeFrame(speed, 1, this.lineSpeed)); speed.on('pointerover', () => this.changeFrame(speed, 1, this.lineSpeed));
mute.on('pointerout', () => this.changeFrame(mute, 0, this.lineMute));
mute.on('pointerover', () => this.changeFrame(mute, 1, this.lineMute));
this.creatBtnOutAndOver(back); this.creatBtnOutAndOver(back);
this.creatBtnOutAndOver(this.pencil); this.creatBtnOutAndOver(this.pencil);
this.creatBtnOutAndOver(this.bin); this.creatBtnOutAndOver(this.bin);
@ -149,13 +170,15 @@ class Game extends Phaser.Scene {
play.on('pointerdown', () => this.clickPlay(play)); play.on('pointerdown', () => this.clickPlay(play));
speed.on('pointerdown', () => this.clickSpeed(speed)); speed.on('pointerdown', () => this.clickSpeed(speed));
back.on('pointerdown', () => this.clickBack()); back.on('pointerdown', () => this.clickBack());
mute.on('pointerdown', () => this.clickMute(mute));
this.pencil.on('pointerdown', () => this.clickPencil()); this.pencil.on('pointerdown', () => this.clickPencil());
this.bin.on('pointerdown', () => this.clickBin()); this.bin.on('pointerdown', () => this.clickBin());
this.plus.on('pointerdown', () => this.clickPlus()); this.plus.on('pointerdown', () => this.clickPlus());
this.input.on('pointerdown', () => this.clickNode()); this.input.on('pointerdown', () => this.clickNode());
this.input.on('drag', this.doDrag); this.input.on('drag', this.doDrag);
this.input.on('dragstart', () => this.pauseScene(play)); this.input.on('dragstart', () => this.dragStart(play));
this.input.on('dragend', () => this.dragEnd());
} }
creatBtnOutAndOver(btn) { creatBtnOutAndOver(btn) {
@ -192,10 +215,13 @@ class Game extends Phaser.Scene {
} }
clickBin() { clickBin() {
console.log("BIN"); if (this.selected !== null) {
this.tree.delete(this.selected); console.log("BIN");
this.tree.delete(this.selected);
this.changeFrame(this.bin, 0); this.changeFrame(this.bin, 0);
this.tryClick();
}
} }
clickPlus() { clickPlus() {
@ -212,11 +238,33 @@ class Game extends Phaser.Scene {
clickBack() { clickBack() {
console.log("BACK"); console.log("BACK");
SPEED_GAME = 1;
this.father.scene.stop('GamingBoard'); this.father.scene.stop('GamingBoard');
this.father.scene.remove('GamingBoard'); this.father.scene.remove('GamingBoard');
this.father.scene.stop('Game'); this.father.scene.stop('Game');
this.father.scene.start('Type'); this.father.scene.start('Type');
} }
clickMute(btn) {
console.log("MUTE");
if (this.father.sound.mute) {
this.father.sound.mute = false;
this.lineMute = 0;
} else {
this.father.sound.mute = true;
this.lineMute = 1;
}
this.changeFrame(btn, 1, this.lineMute);
}
tryClick() {
this.pencil.setVisible(false);
this.bin.setVisible(false);
this.plus.setVisible(false);
if (this.selected != null) {
this.selected.deselect();
this.selected = null;
}
}
} }

@ -14,6 +14,7 @@ class GamingBoard extends Phaser.Scene {
} }
create() { create() {
listBonus.push(new BonusSpeed('Balle Argent', this, WIDTH_MAP / 2, WIDTH_MAP / 2, 3, 2000)); listBonus.push(new BonusSpeed('Balle Argent', this, WIDTH_MAP / 2, WIDTH_MAP / 2, 3, 2000));
this.add.image(0, 0, 'background').alpha = 0.1; this.add.image(0, 0, 'background').alpha = 0.1;
@ -24,9 +25,8 @@ class GamingBoard extends Phaser.Scene {
this.listRobot[0].drawRange(); this.listRobot[0].drawRange();
this.events.on('resume', () => this.resume());
this.time.addEvent({delay: 2000, callback: this.upShield, callbackScope: this}); this.time.addEvent({delay: 2000, callback: this.upShield, callbackScope: this});
} }
update(time, delta) { update(time, delta) {

@ -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);
}
}
}

@ -18,7 +18,7 @@ class PlusNode extends Phaser.Scene {
let y = HEIGHT_WINDOW / 2; let y = HEIGHT_WINDOW / 2;
let diffX = WIDTH_WINDOW / 3; let diffX = WIDTH_WINDOW / 3;
let diffY = HEIGHT_WINDOW / 10; let diffY = HEIGHT_WINDOW / 10;
let sizeText = diffY; let sizeText = diffY / 1.5;
let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"}; let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};

@ -28,6 +28,7 @@ class RectangleNode {
this.lRect = []; this.lRect = [];
this.scene = scene; this.scene = scene;
this.scene.add.existing(this.rect); this.scene.add.existing(this.rect);
this.scene.input.setDraggable(this.rect);
break; break;
default: default:
console.log("Création d'un node echoué"); console.log("Création d'un node echoué");
@ -99,7 +100,7 @@ class RectangleNode {
this.updateLine(true); this.updateLine(true);
} }
updateLine(force) { updateLine(force = false) {
if ((force === true || this.xLine !== this.rect.x || this.yLine !== this.rect.y) && this.line !== undefined) { if ((force === true || this.xLine !== this.rect.x || this.yLine !== this.rect.y) && this.line !== undefined) {
this.xLine = this.rect.x; this.xLine = this.rect.x;
this.yLine = this.rect.y; this.yLine = this.rect.y;
@ -116,14 +117,23 @@ class RectangleNode {
node.setLine(this.rect.x, this.rect.y + this.rect.displayHeight * 0.9); node.setLine(this.rect.x, this.rect.y + this.rect.displayHeight * 0.9);
} }
getNode() {
if (this.canAddNode) {
this.node.clearNodes();
this.lRect.forEach(rect => this.node.addNode(rect.node));
console.log(this);
}
return this.node;
}
getNodes() { getNodes() {
if (this.node === undefined) { if (this.node === undefined) {
let lNodes = []; let lNodes = [];
this.lRect.forEach(function (element) { this.lRect.forEach(function (element) {
if (element.node !== undefined) { if (element.node !== undefined) {
if (element.lRect !== undefined) { if (element.canAddNode) {
element.node.clearNodes(); element.node.clearNodes();
element.lRect.forEach(rect => element.node.addNode(rect.node)); element.lRect.forEach(rect => element.node.addNode(rect.getNode()));
} }
lNodes.push(element.node); lNodes.push(element.node);
} }
@ -133,6 +143,17 @@ class RectangleNode {
} }
sort(sortDesc) {
if (this.canAddNode) {
this.lRect.sort(sortDesc);
this.lRect.forEach(function (element) {
if (element.canAddNode) {
element.sort(sortDesc);
}
})
}
}
destroy() { destroy() {
this.line.destroy(); this.line.destroy();
this.rect.destroy(); this.rect.destroy();

@ -94,7 +94,7 @@ class Robot {
} }
advanceTo(target) { advanceTo(target) {
if (this.target.x !== this.x || this.target.y !== this.y) { if (target.x !== this.x || target.y !== this.y) {
let x = false; let x = false;
let y = false; let y = false;
let velocity = this.getVelocity(target); let velocity = this.getVelocity(target);

@ -1,13 +1,13 @@
class Type extends Phaser.Scene { class Type extends ManageLang {
constructor(father) { constructor(father) {
super('Type'); super('Type', father);
this.father = father;
} }
preload() { preload() {
} }
create() { create() {
super.create();
let style = {font: '200px stencil', fill: "#e2e2e2"}; let style = {font: '200px stencil', fill: "#e2e2e2"};
this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 4, "WARIA", style).setOrigin(0.5, 1); this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 4, "WARIA", style).setOrigin(0.5, 1);

@ -5,6 +5,9 @@ class AddNode extends Phaser.Scene {
this.gameR = game; this.gameR = game;
this.selected = selected; this.selected = selected;
this.lCategory = []; this.lCategory = [];
let sizeText = HEIGHT_WINDOW / 14;
this.style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};
this.heightButton = HEIGHT_WINDOW / 8;
} }
create(son) { create(son) {
@ -16,13 +19,13 @@ class AddNode extends Phaser.Scene {
} }
addButton(x, y, width, height, texture, category = new Category(), value) { addButton(x, y, texture, category = new Category(), value) {
let btn = this.createButton(x, y, width, height, texture); let btn = this.createButton(x, y, texture);
btn.on('pointerdown', () => this.click(btn, category, value)); btn.on('pointerdown', () => this.click(btn, category, value));
return btn; return btn;
} }
createButton(x, y, width, height, texture) { createButton(x, y, texture, height = this.heightButton, width = null) {
let btn = this.add.image(x, y, texture).setOrigin(0.5, 0.5).setInteractive(); let btn = this.add.image(x, y, texture).setOrigin(0.5, 0.5).setInteractive();
btn.on('pointerover', () => btn.setFrame(1)); btn.on('pointerover', () => btn.setFrame(1));
btn.on('pointerout', () => btn.setFrame(0)); btn.on('pointerout', () => btn.setFrame(0));
@ -51,18 +54,16 @@ class AddNode extends Phaser.Scene {
} }
addTitle(x, y, title) { addTitle(x, y, title) {
let sizeText = HEIGHT_WINDOW / 12; this.add.text(x, y, title, this.style).setOrigin(0.5, 0.5);
let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};
this.add.text(x, y, title, style).setOrigin(0.5, 0.5);
} }
createButtonCancel() { createButtonCancel() {
this.createButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 15), null, HEIGHT_WINDOW / 9, 'cancel') this.createButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 15), 'cancel', HEIGHT_WINDOW / 9)
.on('pointerdown', () => this.cancel()); .on('pointerdown', () => this.cancel());
} }
createButtonAdd(son) { createButtonAdd(son) {
this.createButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 15), null, HEIGHT_WINDOW / 9, 'add') this.createButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 15), 'add', HEIGHT_WINDOW / 9)
.on('pointerdown', () => son.addNode()); .on('pointerdown', () => son.addNode());
} }

@ -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…
Cancel
Save