You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
55 lines
1.6 KiB
class AddNode extends Phaser.Scene {
|
|
constructor(game, selected) {
|
|
super('AddNode');
|
|
this.game = game;
|
|
this.selected = selected;
|
|
}
|
|
|
|
create() {
|
|
let height = HEIGHT_WINDOW / (4 / 3);
|
|
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, 0x35363A).setOrigin(0, 0.5);
|
|
this.createButtonCancel();
|
|
this.createButtonAdd();
|
|
}
|
|
|
|
|
|
addButton(x, y, width, height, texture) {
|
|
let btn = this.add.image(x, y, texture).setOrigin(0.5, 0.5).setInteractive();
|
|
btn.on('pointerover', () => btn.setFrame(1));
|
|
btn.on('pointerout', () => btn.setFrame(0));
|
|
btn.displayHeight = height;
|
|
if (width === null) {
|
|
btn.scaleX = btn.scaleY;
|
|
} else {
|
|
btn.displayWidth = width;
|
|
}
|
|
return btn;
|
|
}
|
|
|
|
addTitle(x, y, title) {
|
|
let sizeText = HEIGHT_WINDOW / 12;
|
|
let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};
|
|
this.add.text(x, y, title, style).setOrigin(0.5, 0.5);
|
|
}
|
|
|
|
createButtonCancel() {
|
|
this.addButton(WIDTH_WINDOW / 3, HEIGHT_WINDOW / (16 / 15), null, HEIGHT_WINDOW / 9, 'cancel')
|
|
.on('pointerdown', () => this.cancel());
|
|
}
|
|
|
|
createButtonAdd() {
|
|
this.addButton(WIDTH_WINDOW / 1.5, HEIGHT_WINDOW / (16 / 15), null, HEIGHT_WINDOW / 9, 'add')
|
|
.on('pointerdown', () => this.add());
|
|
}
|
|
|
|
add() {
|
|
|
|
}
|
|
|
|
cancel() {
|
|
this.scene.resume('Game');
|
|
this.scene.stop('AddNode');
|
|
this.game.scene.remove('AddNode');
|
|
}
|
|
} |