Modification : 10 points répartis sur les 4 catégories - AJout d'un descriptif de la barre dans celle-ci en transparent - Modification du positionnement des barres de modification du robot à droite de la carte - Création d'un string sous le format json de l'arbre d'action dans le but de le récupérer et le partager à l'avenir - Grace à ce string en json, lors du changement de la langue, l'arbre se créé sur la sauvagarde de l'ancien arbre => l'arbre est identique à celui d'avant le changement de langue

master
clmaisonha 5 years ago
parent 5b8a587017
commit 680ed6088d

File diff suppressed because one or more lines are too long

@ -1 +1 @@
class AddNode extends Phaser.Scene{constructor(t,e,s){super("AddNode"),this.father=t,this.gameR=e,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(t){let e=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,e,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(t)}addButton(t,e,s,i=new Category,a){let h=this.createButton(t,e,s);return h.on("pointerdown",()=>this.click(h,i,a)),h}createButton(t,e,s,i=this.heightButton,a=null){let h=this.add.image(t,e,s).setOrigin(.5,.5).setInteractive();return h.on("pointerover",()=>h.setFrame(1)),h.on("pointerout",()=>h.setFrame(0)),h.displayHeight=i,null===a?h.scaleX=h.scaleY:h.displayWidth=a,h}click(t,e,s){t.isTinted?e.remove(t):e.add(t,s)}newCategory(t,e,s){let i=new Category(t,e,s);return this.lCategory.push(i),i}addTitle(t,e,s){this.add.text(t,e,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(t){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),"add",HEIGHT_WINDOW/9).on("pointerdown",()=>t.addNode())}verifyCategory(){for(let t=0;t<this.lCategory.length;t++)if(!this.lCategory[t].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(t,e,s,i,a,h){super(e,s,i,a),this.setOrigin(.5,.5),this.displayHeight=HEIGHT_BONUS,this.scaleX=this.scaleY,e.add.existing(this),this.name=t,this.value=h,this.scene=e}}class Finish extends Phaser.Scene{constructor(t){super("Finish"),this.father=t}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(t){let e={font:(HEIGHT_WINDOW/6).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,t,e).setOrigin(.5,.5)}createButton(t,e){let s=this.add.image(t,HEIGHT_WINDOW/8*7,e).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(t){t.on("pointerdown",()=>this.retry())}retry(){console.log("RETRY"),this.close(),newGame(this.father),this.father.scene.start("Game")}btnHome(t){t.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.start("Type")}btnNext(t){t.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 HealthBar{constructor(t,e,s,i,a,h,r,n=COLOR_RED){this.bar=new Phaser.GameObjects.Graphics(t),this.width=Math.floor(e),this.height=Math.floor(s),this.valueMax=h,this.value=h,this.color=r,this.colorMin=n,this.draw(),this.setX(i),this.setY(a),t.add.existing(this.bar)}setValue(t){t<0&&(t=0),t>this.valueMax&&(t=this.valueMax),t!==this.value&&(this.value=t,this.draw())}decrease(t){this.value-=t;let e=0;return this.value<0&&(e=-this.value,this.value=0),this.draw(),e}getBar(){return this.bar}increase(t){this.value+=t,this.value>this.valueMax&&(this.value=this.valueMax),this.draw()}setX(t){this.bar.setX(t-this.width/2)}setY(t){this.bar.setY(t)}draw(){this.bar.clear(),this.bar.fillStyle(0),this.bar.fillRect(0,0,this.width,this.height),this.bar.fillStyle(16777215),this.bar.fillRect(2,2,this.width-4,this.height-4);let t=this.value/this.valueMax;t<1/3?this.bar.fillStyle(this.colorMin):this.bar.fillStyle(this.color);let e=Math.floor(t*(this.width-4));this.bar.fillRect(2,2,e,this.height-4)}destroy(){this.bar.destroy()}}class ManageLang extends Phaser.Scene{constructor(t,e){super(t),this.name=t,this.father=e,this.otherScenes=[]}addOtherScenes(t){this.otherScenes.push(t)}create(){this.createFlags()}createFlags(){this.diffXFlag=0,this.createFlag("fr"),this.createFlag("en")}createFlag(t){let e=this.add.image(WIDTH_WINDOW-10-this.diffXFlag,10,t).setOrigin(1,0).setInteractive();e.displayHeight=40,e.scaleX=e.scaleY,this.diffXFlag=this.diffXFlag+e.displayWidth+10,e.on("pointerdown",()=>this.setLang(t))}setLang(t){t!==LANG&&(LANG=t,this.father.scene.add("LoadFile",new LoadFile(this.father,this.name)),this.father.scene.start("LoadFile"),this.otherScenes.forEach(t=>this.father.scene.stop(t)))}}
class AddNode extends Phaser.Scene{constructor(t,e,s){super("AddNode"),this.father=t,this.gameR=e,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(t){let e=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,e,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(t)}addButton(t,e,s,i=new Category,a){let h=this.createButton(t,e,s);return h.on("pointerdown",()=>this.click(h,i,a)),h}createButton(t,e,s,i=this.heightButton,a=null){let h=this.add.image(t,e,s).setOrigin(.5,.5).setInteractive();return h.on("pointerover",()=>h.setFrame(1)),h.on("pointerout",()=>h.setFrame(0)),h.displayHeight=i,null===a?h.scaleX=h.scaleY:h.displayWidth=a,h}click(t,e,s){t.isTinted?e.remove(t):e.add(t,s)}newCategory(t,e,s){let i=new Category(t,e,s);return this.lCategory.push(i),i}addTitle(t,e,s){this.add.text(t,e,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(t){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),"add",HEIGHT_WINDOW/9).on("pointerdown",()=>t.addNode())}verifyCategory(){for(let t=0;t<this.lCategory.length;t++)if(!this.lCategory[t].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(t,e,s,i,a,h){super(e,s,i,a),this.setOrigin(.5,.5),this.displayHeight=HEIGHT_BONUS,this.scaleX=this.scaleY,e.add.existing(this),this.name=t,this.value=h,this.scene=e}}class Finish extends Phaser.Scene{constructor(t){super("Finish"),this.father=t}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(t){let e={font:(HEIGHT_WINDOW/6).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,t,e).setOrigin(.5,.5)}createButton(t,e){let s=this.add.image(t,HEIGHT_WINDOW/8*7,e).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(t){t.on("pointerdown",()=>this.retry())}retry(){console.log("RETRY"),this.close(),newGame(this.father),this.father.scene.start("Game")}btnHome(t){t.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.start("Type")}btnNext(t){t.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 HealthBar{constructor(t,e,s,i,a,h,r,n=COLOR_RED,l=!0){this.bar=new Phaser.GameObjects.Graphics(t),this.width=Math.floor(e),this.height=Math.floor(s),this.valueMax=h,this.value=h,this.color=r,this.colorMin=n,this.draw(),this.setX(i,l),this.setY(a),t.add.existing(this.bar)}setValue(t){t<0&&(t=0),t>this.valueMax&&(t=this.valueMax),t!==this.value&&(this.value=t,this.draw())}decrease(t){this.value-=t;let e=0;return this.value<0&&(e=-this.value,this.value=0),this.draw(),e}getBar(){return this.bar}increase(t){this.value+=t,this.value>this.valueMax&&(this.value=this.valueMax),this.draw()}setX(t,e=!0){e?this.bar.setX(t-this.width/2):this.bar.setX(t)}setY(t){this.bar.setY(t)}draw(){this.bar.clear(),this.bar.fillStyle(0),this.bar.fillRect(0,0,this.width,this.height),this.bar.fillStyle(16777215),this.bar.fillRect(2,2,this.width-4,this.height-4);let t=this.value/this.valueMax;t<1/3?this.bar.fillStyle(this.colorMin):this.bar.fillStyle(this.color);let e=Math.floor(t*(this.width-4));this.bar.fillRect(2,2,e,this.height-4)}destroy(){this.bar.destroy()}}class ManageLang extends Phaser.Scene{constructor(t,e){super(t),this.name=t,this.father=e,this.otherScenes=[]}addOtherScenes(t){this.otherScenes.push(t)}create(){this.createFlags()}createFlags(){this.diffXFlag=0,this.createFlag("fr"),this.createFlag("en")}createFlag(t){let e=this.add.image(WIDTH_WINDOW-10-this.diffXFlag,10,t).setOrigin(1,0).setInteractive();e.displayHeight=40,e.scaleX=e.scaleY,this.diffXFlag=this.diffXFlag+e.displayWidth+10,e.on("pointerdown",()=>this.setLang(t))}setLang(t){t!==LANG&&(LANG=t,this.father.scene.add("LoadFile",new LoadFile(this.father,this.name)),this.father.scene.start("LoadFile"),this.otherScenes.forEach(t=>this.father.scene.stop(t)))}}

@ -1,10 +1,19 @@
class Bar extends HealthBar {
constructor(scene, width, height, x, y, color, categoryBar = new CategoryBar(), value = 1) {
super(scene, width, height, x, y, categoryBar.valueMax, color, color);
constructor(scene, name = "", width, height, x, y, color, categoryBar = new CategoryBar(), value = 1, valueMax) {
if (valueMax !== undefined) {
super(scene, width, height, x, y, valueMax, color, color, false);
} else {
super(scene, width, height, x, y, categoryBar.valueMax, color, color, false);
}
this.name = name;
this.scene = scene;
this.scene.input.on('pointerdown', this.doDrag, this);
let style = {font: height.toString() + 'px stencil', fill: "#e2e2e2"};
this.text = this.scene.add.text(this.bar.x + this.width + 10, this.bar.y, this.value.toString(), style).setOrigin(0, 0);
style = {font: height.toString() + 'px stencil', fill: "#000000"};
let nameText = this.scene.add.text(x + 5, y, this.name, style).setOrigin(0, 0);
nameText.alpha = 0.5;
this.categoryBar = categoryBar;
this.setValue(0);
this.categoryBar.setValueOf(this, value);

@ -1,8 +1,12 @@
class CategoryBar {
constructor(startValue = 1, valueMax = VALUE_MAX_BAR) {
constructor(scene, text, posX, posY, height, valueMax = VALUE_MAX_BAR, startValue = 1) {
this.startValue = startValue;
this.valueMax = valueMax;
this.point = this.valueMax;
this.text = text;
let style = {font: height.toString() + 'px stencil', fill: "#e2e2e2"};
this.textScene = scene.add.text(posX, posY, this.text, style).setOrigin(0, 0);
this.draw();
}
addPoint(point) {
@ -27,5 +31,10 @@ class CategoryBar {
bar.setValue(bar.value + this.point);
}
this.addPoint(oldValue - bar.value);
this.draw();
}
draw(){
this.textScene.setText(this.text + this.point);
}
}

@ -1,8 +1,14 @@
var tree = undefined;
class Game extends ManageLang {
constructor(father) {
constructor(father, saveTree) {
super('Game', father);
super.addOtherScenes('GamingBoard');
SPEED_GAME = 1;
if (saveTree !== undefined) {
this.tree = JSON.parse(saveTree);
this.loadSave(this.tree);
}
}
create() {
@ -18,17 +24,20 @@ class Game extends ManageLang {
this.selected = null;
let c1 = new CategoryBar();
this.damageRobot = new Bar(this, 200, 30, OFFX_MAP + WIDTH_MAP / 4, OFFY_MAP / 2, COLOR_ATTACK, c1, DAMAGE_BEGIN);
this.speedReloadRobot = new Bar(this, 200, 30, OFFX_MAP + WIDTH_MAP / 4, 0, COLOR_SPEED_RELOAD, c1, SPEED_RELOAD_BEGIN);
let c2 = new CategoryBar();
this.speedRobot = new Bar(this, 200, 30, OFFX_MAP + WIDTH_MAP / 4 * 3, 0, COLOR_MOVE, c2, SPEED_BEGIN);
this.rangeRobot = new Bar(this, 200, 30, OFFX_MAP + WIDTH_MAP / 4 * 3, OFFY_MAP / 2, COLOR_RANGE, c2, RANGE_BEGIN);
let width = 200;
let height = 30;
let c1 = new CategoryBar(this, selectWord("TOKEN : ", "JETON : "), OFFX_MAP + WIDTH_MAP + 5, OFFY_MAP + height * 6, height, 10);
this.damageRobot = new Bar(this, selectWord("DAMAGE", "DEGAT"), width, height, OFFX_MAP + WIDTH_MAP + 5, OFFY_MAP, COLOR_ATTACK, c1, DAMAGE_BEGIN, 5);
this.speedReloadRobot = new Bar(this, selectWord("R.S", "V.R."), width, height, OFFX_MAP + WIDTH_MAP + 5, OFFY_MAP + height * 1.5, COLOR_SPEED_RELOAD, c1, SPEED_RELOAD_BEGIN, 5);
this.speedRobot = new Bar(this, selectWord("SPEED", "VITESSE"), width, height, OFFX_MAP + WIDTH_MAP + 5, OFFY_MAP + height * 3, COLOR_MOVE, c1, SPEED_BEGIN, 5);
this.rangeRobot = new Bar(this, selectWord("RANGE", "PORTEE"), width, height, OFFX_MAP + WIDTH_MAP + 5, OFFY_MAP + height * 4.5, COLOR_RANGE, c1, RANGE_BEGIN, 5);
this.createButton();
let centerX = WIDTH_WINDOW / 4 * 3;
let diffX = WIDTH_WINDOW / 10;
if (this.tree === undefined) {
this.tree = new RectangleNode(centerX, HEIGHT_WINDOW / 10, this, 'waria');
this.tree.addRect(new RectangleNode(centerX - 2 * diffX, HEIGHT_WINDOW / 3, this, 'move', true, false));
this.tree.addRect(new RectangleNode(centerX + diffX, HEIGHT_WINDOW / 3, this, 'move', true));
@ -36,13 +45,20 @@ class Game extends ManageLang {
let condition = new RectangleNode(centerX - diffX, HEIGHT_WINDOW / 3, this, 'condition', true, true, false, 1 / 3, 0);
this.tree.addRect(condition);
condition.addRect(new RectangleNode(centerX, HEIGHT_WINDOW / 1.5, this, 'move', false));
condition.addRect(new RectangleNode(centerX - diffX, HEIGHT_WINDOW / 1.5, this, 'attack'))
this.tree.addRect(condition);
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.1, WIDTH_MAP * 0.9, 0xff0000, this.gm));
} else {
let save = this.tree.save();
save = JSON.parse(save);
this.loadSave(save);
}
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, WIDTH_MAP * 0.9, this.gm, MYSELF));
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.2, WIDTH_MAP * 0.1, this.gm));
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, this.gm));
this.input.keyboard.on('keydown-DELETE', () => {
@ -56,6 +72,19 @@ class Game extends ManageLang {
this.tree.updateLine();
}
loadSave(save) {
this.tree = this.loadTree(save);
}
loadTree(element) {
let tree = new RectangleNode(element.x, element.y, this, element.type, element.option);
if (element.lRect !== undefined && element.lRect.length > 0) {
element.lRect.forEach(rect => tree.addRect(this.loadTree(rect)))
}
return tree;
}
finish() {
console.log("FINISH");
let winner;
@ -132,10 +161,10 @@ class Game extends ManageLang {
}
createButton() {
let x = WIDTH_MAP + WIDTH_WINDOW / 10;
let y = WIDTH_MAP + HEIGHT_WINDOW / 10 + 5;
let diffX = (HEIGHT_WINDOW / 10);
let width = HEIGHT_WINDOW / 15;
let x = WIDTH_MAP + OFFX_MAP;
let y = WIDTH_MAP + OFFY_MAP + 5;
let width = OFFY_MAP / 1.5;
let diffX = width * 1.1;
let back = this.add.sprite(10, 10, 'back').setOrigin(0, 0).setInteractive();

@ -37,6 +37,8 @@ class RectangleNode {
if (type.toString().toLowerCase() !== 'waria') {
this.rect.setFrame(this.node.getFrame());
}
this.option = option;
this.type = type;
this.rect.on('pointerdown', () => this.click());
this.rect.setOrigin(0.5, 0);
this.rect.displayHeight = HEIGHT_WINDOW / 6;
@ -94,6 +96,46 @@ class RectangleNode {
}
}
toJson(name, value, end = false) {
let val;
if (typeof value === "string") {
val = '"' + name.toString() + '":"' + value + '"';
} else {
val = '"' + name.toString() + '":' + value;
}
if (!end)
val += ','
return val;
}
endLineJson(json) {
if (json.length > 0) {
if (json[json.length - 1] === ",") {
json = json.substr(0, json.length - 1);
}
}
return json;
}
save() {
let json = '{';
json += this.toJson("x", this.rect.x) + this.toJson("y", this.rect.y) + this.toJson("type", this.type);
json += '"option":[';
this.option.forEach(option => json += option + ',');
json = this.endLineJson(json) + '],';
if (this.canAddNode) {
json += '"lRect":[';
this.lRect.forEach(rect => json += rect.save() + ',');
json = this.endLineJson(json) + ']';
}
json = this.endLineJson(json);
json += '}';
console.log(json)
return json;
}
setLine(x, y) {
this.xOrigin = x;
this.yOrigin = y;

@ -1,5 +1,5 @@
class Robot {
constructor(height, width, posX, posY, color, scene, name = 'enemy') {
constructor(height, width, posX, posY, scene, name = 'enemy') {
this.speed = SPEED_BASE + SPEED_BEGIN;
this.speedReload = SPEED_RELOAD_BASE + SPEED_RELOAD_BEGIN;
this.range = RANGE_BASE + RANGE_BEGIN;
@ -10,7 +10,6 @@ class Robot {
this.width = width;
this.x = posX;
this.y = posY;
this.color = color;
this.life = new HealthBar(scene, this.width * 2, this.width / 3, this.x, this.y - this.width, LIFE, 0x008000);
this.shield = new HealthBar(scene, this.width * 2, this.width / 3, this.x, this.y - this.width * 1.5, SHIELD, 0x0000FF);
this.circleRange = null;
@ -36,7 +35,7 @@ class Robot {
this.circle = this.scene.add.image(this.x, this.y, 'enemy').setOrigin(0.5, 0.5).setInteractive();
this.circle.displayWidth = this.circle.displayHeight = this.width;
} else {
this.circle = this.scene.add.circle(this.x, this.y, this.width / 2, this.color).setInteractive();
this.circle = this.scene.add.circle(this.x, this.y, this.width / 2, COLOR_MYSELF).setInteractive();
}
this.circle.on('pointerdown', () => this.click());
}

@ -11,11 +11,13 @@ const COLOR_ORANGE = 0xff7f00;
const COLOR_GREEN = 0x008000;
const COLOR_RANGE = 0x008000;
const COLOR_SPEED_RELOAD = 0x7f00ff;
const COLOR_MYSELF = 0x6666ff;
const WIDTH_WINDOW = $(document).width() - 20;
const HEIGHT_WINDOW = $(document).height() - 20;
const WIDTH_MAP = WIDTH_WINDOW < HEIGHT_WINDOW ? WIDTH_WINDOW * 0.8 : HEIGHT_WINDOW * 0.8;
const OFFX_MAP = WIDTH_WINDOW / 20;
const OFFY_MAP = WIDTH_WINDOW / 20;
const OFFY_MAP = (HEIGHT_WINDOW - WIDTH_MAP) / 2;
const LIFE = 100;
const SHIELD = 100;

@ -1,5 +1,5 @@
class HealthBar {
constructor(scene, width, height, x, y, valueMax, color, colorMin = COLOR_RED) {
constructor(scene, width, height, x, y, valueMax, color, colorMin = COLOR_RED, middle = true) {
this.bar = new Phaser.GameObjects.Graphics(scene);
this.width = Math.floor(width);
@ -11,7 +11,7 @@ class HealthBar {
this.draw();
this.setX(x);
this.setX(x, middle);
this.setY(y);
scene.add.existing(this.bar);
}
@ -55,8 +55,11 @@ class HealthBar {
this.draw();
}
setX(x) {
setX(x, middle= true) {
if(middle)
this.bar.setX(x - this.width / 2);
else
this.bar.setX(x);
}
setY(y) {

Loading…
Cancel
Save