started skeleton and zombie, added GUI and menu system
Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
+34
-3
@@ -5,18 +5,49 @@
|
||||
|
||||
export default class TextElement {
|
||||
constructor(scene, item) {
|
||||
scene.add.text(item.x, item.y, item.text.text, {
|
||||
this.scene = scene;
|
||||
this.text = scene.add.text(item.x, item.y, item.text.text, {
|
||||
fontFamily: item.text.fontfamily || "Consolas",
|
||||
fontSize: item.text.pixelsize || 16,
|
||||
align: item.text.valign || "center",
|
||||
align: item.text.halign || "center",
|
||||
fontStyle: item.text.bold ? "strong" : "",
|
||||
fixedHeight: item.height,
|
||||
fixedWidth: item.width,
|
||||
color: item.text.color || "#ffffff",
|
||||
color: item.text.color || "#000000",
|
||||
wordWrap: {
|
||||
width: item.width,
|
||||
useAdvancedWrap: item.text.wrap
|
||||
}
|
||||
})
|
||||
|
||||
if (item.name === "action") {
|
||||
this.text.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.text.width, this.text.height), Phaser.Geom.Rectangle.Contains)
|
||||
.on('pointerdown', () => {
|
||||
let action = item.properties.filter(obj => obj.name === "action");
|
||||
if (action.length <= 0)
|
||||
return;
|
||||
|
||||
action = action[0].value;
|
||||
|
||||
switch (action) {
|
||||
case "pause_resume":
|
||||
this.endMyself();
|
||||
scene.scene.resume('Game');
|
||||
break;
|
||||
case "pause_exit":
|
||||
this.endMyself();
|
||||
scene.scene.stop('Game');
|
||||
|
||||
scene.scene.start('GUI', {key: 'MainMenu'});
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
endMyself() {
|
||||
this.scene.scene.stop();
|
||||
this.scene.scene.setVisible(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user