Ajout du sprite bouton "cancel" - Ajout de la scène ajouter Action lorsqu'on clique sur le plus "+" - Désactivation de toute les interactions avec la scène en arriere plan - Ajout du bouton cancel pour abandonner l'ajout et revenir à la page principale - Mise en forme de la sélection de l'action à rajouté (pour le moment ça n'execute aucune interface mais détecte bien sur quelle image je clique (Action, Mouvement, Condition), affiche la sélection dans las console)
parent
e5f3c4b3e1
commit
ae086c87a1
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 4.6 KiB |
File diff suppressed because one or more lines are too long
@ -0,0 +1,65 @@
|
||||
class PlusNode extends Phaser.Scene {
|
||||
constructor() {
|
||||
super('PlusNode');
|
||||
}
|
||||
|
||||
create() {
|
||||
this.add.rectangle(0, 0, WIDTH_WINDOW, HEIGHT_WINDOW, 0x000000).setOrigin(0, 0).setAlpha(0.5);
|
||||
this.add.rectangle(0, HEIGHT_WINDOW / 2, WIDTH_WINDOW, HEIGHT_WINDOW / 2, 0x35363A).setOrigin(0, 0.5);
|
||||
this.createNode();
|
||||
this.createButton();
|
||||
}
|
||||
|
||||
createNode() {
|
||||
let x = WIDTH_WINDOW / 2;
|
||||
let y = HEIGHT_WINDOW / 2;
|
||||
let diffX = WIDTH_WINDOW / 4;
|
||||
let diffY = HEIGHT_WINDOW / 10;
|
||||
let sizeText = diffY;
|
||||
|
||||
let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};
|
||||
|
||||
this.add.text(x - diffX, y - diffY, "ATTACK", style).setOrigin(0.5, 0.5);
|
||||
this.add.text(x, y - diffY, "MOVE", style).setOrigin(0.5, 0.5);
|
||||
this.add.text(x + diffX, y - diffY, "CONDITION", style).setOrigin(0.5, 0.5);
|
||||
|
||||
this.add.sprite(x - diffX, y + diffY, 'attack').setOrigin(0.5, 0.5).setInteractive()
|
||||
.on('pointerdown', () => this.click('attack'));
|
||||
this.add.sprite(x, y + diffY, 'move').setOrigin(0.5, 0.5).setInteractive()
|
||||
.on('pointerdown', () => this.click('move'));
|
||||
this.add.sprite(x + diffX, y + diffY, 'condition').setOrigin(0.5, 0.5).setInteractive()
|
||||
.on('pointerdown', () => this.click('condition'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
click(action) {
|
||||
switch (action.toString()) {
|
||||
case 'attack':
|
||||
|
||||
break;
|
||||
case 'move':
|
||||
|
||||
break;
|
||||
|
||||
case 'condition':
|
||||
|
||||
break;
|
||||
}
|
||||
console.log(action.toString());
|
||||
}
|
||||
|
||||
createButton() {
|
||||
let x = WIDTH_WINDOW / 2;
|
||||
let y = HEIGHT_WINDOW - 100;
|
||||
this.cancelBtn = this.add.image(x, y, 'cancel').setOrigin(0.5, 0.5).setInteractive();
|
||||
this.cancelBtn.on('pointerover', () => this.cancelBtn.setFrame(1));
|
||||
this.cancelBtn.on('pointerout', () => this.cancelBtn.setFrame(0));
|
||||
this.cancelBtn.on('pointerdown', () => this.cancel());
|
||||
}
|
||||
|
||||
cancel() {
|
||||
this.scene.resume('Game');
|
||||
this.scene.stop('PlusNode');
|
||||
}
|
||||
}
|
Loading…
Reference in new issue