Hi.
I have a popup entity in my scene with some text. I enable the popup when both players are ready to act, and disable it when a proper player press key A.
But when the fight ends i want to show ‘WON’ text in this popup.
Here’s the project
Check the won message handling. I set text attrivute to ‘WON’ and call updateText function of text script. But instead of new text i have a completly blank popup.
Can you help me with this?
Had a quick look and using rgba for fillStyle seems to work.
Text.prototype.updateText = function() {
var ctx = this.context;
var w = ctx.canvas.width;
var h = ctx.canvas.height;
ctx.fillStyle = 'rgba(0, 0, 0, 1)';
ctx.fillRect(0, 0, w, h);
// Write white text
ctx.fillStyle = 'white';
ctx.save();
ctx.font = 'bold 48px Verdana';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(this.text, w / 2, h / 2);
ctx.restore();
// Copy the canvas into the texture
this.texture.upload();
};
I found this out by adding some scaffolding code in the update loop to change the text on a keyboard press and systematically removed each line of code till I found the offending line that caused the white popup.
Thanks a lot, it works!