51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
|
const asdf = require("asdf-games");
|
||
|
// eslint-disable-next-line no-unused-vars
|
||
|
const { Texture, Container, Sprite, Text } = asdf;
|
||
|
|
||
|
const text = require(__dirname + "/../../res/lang/default.js");
|
||
|
const fillStyle = {fill: "#ffffff", font: "24px Arial"};
|
||
|
|
||
|
class Title extends Container {
|
||
|
constructor(game, keys, onStart, onTutorial, onQuit) {
|
||
|
super();
|
||
|
this.game = game;
|
||
|
this.keys = keys;
|
||
|
|
||
|
this.onStart = onStart;
|
||
|
this.onTutorial = onTutorial;
|
||
|
this.onQuit = onQuit;
|
||
|
|
||
|
this.keys.reset();
|
||
|
|
||
|
this.children = [];
|
||
|
|
||
|
const textPos = { x: 200, y: 200 };
|
||
|
for (let index = 0; index < text.titleScreen.instructions.length; index++) {
|
||
|
const element = new Text(text.titleScreen.instructions[index], fillStyle);
|
||
|
element.pos = {
|
||
|
x: textPos.x,
|
||
|
y: textPos.y + 28 * index
|
||
|
};
|
||
|
this.add(element);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
update(dt, t) {
|
||
|
super.update(dt, t);
|
||
|
|
||
|
if (this.keys.action) {
|
||
|
this.onStart();
|
||
|
}
|
||
|
|
||
|
if (this.keys.key(84)) {
|
||
|
this.onTutorial();
|
||
|
}
|
||
|
|
||
|
if (this.keys.key(81)) {
|
||
|
this.onQuit();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = Title;
|