function AnnounceBox(x, y) { this.posX = x; this.posY = y; } AnnounceBox.prototype.drawText = function(posX, posY, text) { var style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; var textObject = game.add.text( posX, posY, text, style ); textObject.anchor.set(0.5); textObject.stroke = "#333"; textObject.strokeThickness = 3; return textObject; } AnnounceBox.prototype.getFontStyle = function() { return { font: "32px Arial", fill: "#fff" }; } AnnounceBox.prototype.drawBox = function(text) { this.graphics = game.add.graphics(this.posX, this.posY); this.graphics.alpha = 0.8; this.graphics.beginFill(0x303030); this.graphics.lineStyle(4, 0x880000, 1); this.graphics.moveTo(0, -190); this.graphics.lineTo(game.world.width / 2, -170); this.graphics.lineTo(game.world.width - this.posX * 2, -190); this.graphics.lineTo(game.world.width - this.posX * 2, 50); this.graphics.lineTo(game.world.width / 2, 30); this.graphics.lineTo(0, 50); this.graphics.endFill(); var announceText = this.drawText( game.world.width / 2, this.posY - 75, text ); announceText.addColor("#ff0000", 0); announceText.stroke = "#330000"; }