Création d'un écran de chargement au lancement du jeu dans le but d'avoir un aperçu du temps d'attente(le temps que les images soient téléchargées) - Création des rectangles de mouvements (bleu) et d'attaque (rouge), modifier leur ordre modifie les actions du robot bleu, création des lignes qui les relient avec waria.
parent
9ba17166a7
commit
fa4d5bc7f3
After Width: | Height: | Size: 9.5 KiB |
@ -1 +1 @@
|
||||
const WIDTH_WINDOW=$(document).width()-30,HEIGHT_WINDOW=$(document).height()-30,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"},game=new Phaser.Game(config);game.scene.add("Boot",Boot),game.scene.add("Type",Type),game.scene.add("Game",new Game(game)),game.scene.start("Boot");
|
||||
const COLOR_ATTACK=16711680,COLOR_MOVE=255,WIDTH_WINDOW=$(document).width()-30,HEIGHT_WINDOW=$(document).height()-30,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"},game=new Phaser.Game(config);game.scene.add("Boot",Boot),game.scene.add("Type",Type),game.scene.add("Game",new Game(game)),game.scene.start("Boot");
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,28 @@
|
||||
class AttackRectangle extends Attack {
|
||||
constructor(x, y, width, height, scene) {
|
||||
super();
|
||||
this.color = COLOR_ATTACK;
|
||||
this.rect = new Phaser.GameObjects.Rectangle(scene, x, y, width, height, this.color);
|
||||
this.line = scene.add.graphics();
|
||||
}
|
||||
|
||||
getX() {
|
||||
return this.rect.x;
|
||||
}
|
||||
|
||||
addLine(x, y) {
|
||||
this.xOrigin = x;
|
||||
this.yOrigin = y;
|
||||
this.updateLine();
|
||||
}
|
||||
|
||||
updateLine() {
|
||||
if (this.xLine !== this.rect.x || this.yLine !== this.rect.y) {
|
||||
this.xLine = this.rect.x;
|
||||
this.yLine = this.rect.y;
|
||||
this.line.clear();
|
||||
this.line.lineStyle(10, 0xffffff, 1);
|
||||
this.line.lineBetween(this.xOrigin, this.yOrigin, this.rect.x, this.rect.y);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
class MoveRectangle extends Move {
|
||||
constructor(toward, x, y, width, height, scene) {
|
||||
super(toward);
|
||||
this.color = COLOR_MOVE;
|
||||
this.rect = new Phaser.GameObjects.Rectangle(scene, x, y, width, height, this.color);
|
||||
this.line = scene.add.graphics();
|
||||
}
|
||||
|
||||
getX() {
|
||||
return this.rect.x;
|
||||
}
|
||||
|
||||
addLine(x, y) {
|
||||
this.xOrigin = x;
|
||||
this.yOrigin = y;
|
||||
this.updateLine();
|
||||
}
|
||||
|
||||
updateLine() {
|
||||
if (this.xLine !== this.rect.x || this.yLine !== this.rect.y) {
|
||||
this.xLine = this.rect.x;
|
||||
this.yLine = this.rect.y;
|
||||
this.line.clear();
|
||||
this.line.lineStyle(10, 0xffffff, 1);
|
||||
this.line.lineBetween(this.xOrigin, this.yOrigin, this.rect.x, this.rect.y);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
class Tree {
|
||||
constructor(x, y, scene) {
|
||||
this.lNode = [];
|
||||
this.scene = scene;
|
||||
this.head = this.scene.add.image(x, y, 'logoWaria').setOrigin(0.5, 0.5);
|
||||
this.head.displayHeight = HEIGHT_WINDOW / 4;
|
||||
this.head.scaleX = this.head.scaleY;
|
||||
}
|
||||
|
||||
addNode(node) {
|
||||
this.lNode.push(node);
|
||||
node.addLine(this.head.x, this.head.y + this.head.displayHeight / 2.2);
|
||||
let rect = this.scene.add.existing(node.rect);
|
||||
rect.setInteractive();
|
||||
this.scene.input.setDraggable(rect);
|
||||
}
|
||||
|
||||
updateLines() {
|
||||
this.lNode.forEach(node => node.updateLine());
|
||||
}
|
||||
}
|
Loading…
Reference in new issue