caa-game/src/screens/tutorial.js

38 lines
863 B
JavaScript

const asdf = require("asdf-games");
// eslint-disable-next-line no-unused-vars
const { Texture, Container, Text, Sprite } = asdf;
const text = require(__dirname + "/../../res/lang/default.js");
const fillStyle = {fill: "#ffffff", font: "20px Arial"};
class Tutorial extends Container {
constructor(game, keys, onEnd) {
super();
this.game = game;
this.keys = keys;
this.onEnd = onEnd;
this.children = [];
const textPos = { x: 50, y: 150 };
for (let index = 0; index < text.tutorial.length; index++) {
const element = new Text(text.tutorial[index], fillStyle);
element.pos = {
x: textPos.x,
y: textPos.y + 24 * index
};
this.add(element);
}
}
update(dt, t) {
super.update(dt, t);
if (this.keys.action) {
this.onEnd();
}
}
}
module.exports = Tutorial;