• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript for some reason this text doesnt show up

bram

Coder
JavaScript:
                aimCanvas.ctx.fillStyle = "#404040";
                aimCanvas.ctx.textAlign = "center";
                aimCanvas.ctx.textBaseline = "center";
                aimCanvas.ctx.font = "50px Open Sans";
                aimCanvas.ctx.fillText("End", this.centerLeft, this.centerTop - 20);
                aimCanvas.ctx.font = "30px Open Sans";
                aimCanvas.ctx.fillText("Total Score : " + this.mode.score, this.centerLeft, this.centerTop + 20);
                aimCanvas.ctx.fillText("Total Fails : " + this.mode.shootFail, this.centerLeft, this.centerTop + 45);
                -------------------aimCanvas.ctx.fillText("End Score: " + this.mode.score - this.mode.shootFail, this.centerLeft, this.centertop + 70);-----------------------
                aimCanvas.ctx.fillText("Press ESCAPE", this.centerLeft, this.centerTop + 200);
rJTx9hW.png


for some reason the highlighted (------) part doesnt show up. and I cant figure out why it doesnt show up
 

bram

Coder
JavaScript:
                aimCanvas.ctx.fillText("End Score : " + this.mode.score, this.centerLeft, this.centerTop + 70);
                aimCanvas.ctx.fillText("End Score : " + this.mode.score, this.centerLeft, this.centertop + 70);
line on is the one working (wich I now copied from the working line with total score in it)
and the one below wich you suggested removing the - this.mode.shootFail
if I add - this.mode.shootFail I get NaN as an error
 
Last edited by a moderator:

cbreemer

King Coder
JavaScript:
              aimCanvas.ctx.fillText("End Score: " + this.mode.score - this.mode.shootFail, this.centerLeft, this.centertop + 70);
I think this code attempts to subtract a numeric value (this.mode.shootFail) from a string ("End Score: " + this.mode.score), and throwing a NaN excption because a string is not a number. Try this instead
JavaScript:
              aimCanvas.ctx.fillText("End Score: " + (this.mode.score - this.mode.shootFail), this.centerLeft, this.centertop + 70);
 
Top