diff --git a/public/js/game.js b/public/js/game.js index 466a8fe..aaf103d 100644 --- a/public/js/game.js +++ b/public/js/game.js @@ -164,30 +164,32 @@ function start_game() { score_button_text.x = sprite_size * 3 + 25 - sprite_size * 0.2; score_button_text.y = sprite_size * 7 + 25 - sprite_size * 0.2 + sprite_size * 0.5; - socket.on('updatePlayerNames', function (playerNames) { - - this.playerNames = playerNames; - - score_button = new PIXI.Graphics(); - score_button.lineStyle(4, 0x000000, 1); - score_button.beginFill(0x7d7d7d); - score_button.drawRect(sprite_size * 3 - sprite_size * 0.2, sprite_size * 7 - sprite_size * 0.2 + sprite_size * 0.5, score_button_text.width + 50, score_button_text.height + 50); - score_button.endFill(); - score_button.interactive = true; - score_button.buttonMode = true; - score_button.defaultCursor = 'pointer'; - score_button.on('pointerdown', function () { - card = new Card(game_board_size, "", - { "text": playerNames[0]? playerNames[0] + ": " + positions[0] : ("Kein Spieler"), "status": false }, - { "text": playerNames[1]? playerNames[1] + ": " + positions[1] : ("Kein Spieler"), "status": false }, - { "text": playerNames[2]? playerNames[2] + ": " + positions[2] : ("Kein Spieler"), "status": false }, - { "text": playerNames[3]? playerNames[3] + ": " + positions[3] : ("Kein Spieler"), "status": false }, 0, false); - card.showCard(); - show_card = true; - }); + score_button = new PIXI.Graphics(); + score_button.lineStyle(4, 0x000000, 1); + score_button.beginFill(0x7d7d7d); + score_button.drawRect(sprite_size * 3 - sprite_size * 0.2, sprite_size * 7 - sprite_size * 0.2 + sprite_size * 0.5, score_button_text.width + 50, score_button_text.height + 50); + score_button.endFill(); + score_button.interactive = true; + score_button.buttonMode = true; + score_button.defaultCursor = 'pointer'; + score_button.on('pointerdown', function () { + card = new Card(game_board_size, "", + {"text": playerNames[0] ? playerNames[0] + ": " + positions[0] : ("Kein Spieler"), "status": false}, + {"text": playerNames[1] ? playerNames[1] + ": " + positions[1] : ("Kein Spieler"), "status": false}, + {"text": playerNames[2] ? playerNames[2] + ": " + positions[2] : ("Kein Spieler"), "status": false}, + { + "text": playerNames[3] ? playerNames[3] + ": " + positions[3] : ("Kein Spieler"), + "status": false + }, 0, false); + card.showCard(); + show_card = true; + }); - app.stage.addChild(score_button); - score_button.addChild(score_button_text); + app.stage.addChild(score_button); + score_button.addChild(score_button_text); + + socket.on('updatePlayerNames', function (p) { + playerNames = p; });