Fixed long questions and answers

This commit is contained in:
2021-06-14 13:14:16 +02:00
parent aa6d67fd33
commit 566c03d33a
5 changed files with 46 additions and 2432 deletions

View File

@@ -1,4 +1,4 @@
function Button(default_color, hover_color, select_color, width, height, x, y, text, status, button_is_answer, click) {
function Button(default_color, hover_color, select_color, width, height, x, y, text, status, click) {
this.graphics = new PIXI.Graphics();
this.default_color = default_color;
this.hover_color = hover_color;
@@ -8,7 +8,6 @@ function Button(default_color, hover_color, select_color, width, height, x, y, t
this.y = y;
this.text = text;
this.status = status;
this.button_is_answer = button_is_answer;
this.pointerdown = click;
this.selected = false;
let _this = this;
@@ -35,9 +34,11 @@ function Button(default_color, hover_color, select_color, width, height, x, y, t
this.getButton = function () {
const style = new PIXI.TextStyle({
fontFamily: 'Arial',
fontSize: 60,
fontSize: 40,
wordWrap: true,
wordWrapWidth: game_board_size * 0.5 - 20,
wordWrapWidth: this.width,
breakWords: true,
lineJoin: 'miter'
});
this.graphics.clear();

View File

@@ -21,7 +21,7 @@ function Card(game_board_size, s, a1, a2, a3, a4, d, your_turn) {
this.showCard = function () {
const style = new PIXI.TextStyle({
fontFamily: 'Arial',
fontSize: 60,
fontSize: 50,
wordWrap: true,
wordWrapWidth: game_board_size * 0.5 - 20,
});
@@ -49,25 +49,25 @@ function Card(game_board_size, s, a1, a2, a3, a4, d, your_turn) {
this.card.addChild(basicText);
// Answers
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 4, this.a1.text, this.a1.status, true, function () {
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 200, this.card_x + 20, this.card_y + this.card_height - 120 - 220 * 4, this.a1.text, this.a1.status, function () {
if (_this.your_turn) {
select_answer(0, _this.a1.text);
}
}));
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 3, this.a2.text, this.a2.status, true, function () {
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 200, this.card_x + 20, this.card_y + this.card_height - 120 - 220 * 3, this.a2.text, this.a2.status, function () {
if (_this.your_turn) {
select_answer(1, _this.a2.text);
}
}));
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 2, this.a3.text, this.a3.status, true, function () {
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 200, this.card_x + 20, this.card_y + this.card_height - 120 - 220 * 2, this.a3.text, this.a3.status, function () {
if (_this.your_turn) {
select_answer(2, _this.a3.text);
}
}));
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 1, this.a4.text, this.a4.status, true, function () {
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 200, this.card_x + 20, this.card_y + this.card_height - 120 - 220 * 1, this.a4.text, this.a4.status, function () {
if (_this.your_turn) {
select_answer(3, _this.a4.text);
}
@@ -77,7 +77,7 @@ function Card(game_board_size, s, a1, a2, a3, a4, d, your_turn) {
// OK-Button
this.card.addChild(new Button(0xffffff, 0xcccccc, 0xffffff, this.card_width - 40, 100, this.card_x + 20, this.card_y + this.card_height - 120, "OK", null, false, function () {
this.card.addChild(new Button(0xffffff, 0xcccccc, 0xffffff, this.card_width - 40, 100, this.card_x + 20, this.card_y + this.card_height - 120, "OK", null, function () {
if (answer !== null) {
if (_this.right_answer === answer) {
console.log("Richtig");