0
所以基本上我得到了一小段代碼來檢查遊戲的結束,當你殺死所有的敵人和GameOver時,它應該顯示勝利。事情是,用這段代碼,「勝利」號發生,但被擊敗時,他並沒有表現出任何東西(調試器顯示的字符串是正確的壽)Canvas not creating text
playing=false;
gameOver=true;
var resultText="You Lost!";
if(enemies.length==0){
Debugger.log("VICTORY!");
resultText="VICTORY!";
}
context.font = "70px Comic Sans MS";
context.fillStyle = grd;
context.textAlign = "center";
Debugger.log("ResultText: "+ resultText);
context.fillText(resultText, canvas.width/2, canvas.height/2);
我的grd工作得很好,正如我所說,他甚至在filltext中展示了「勝利」部分,這只是他不寫的「你輸了」。 //創建梯度 grd = context.createLinearGradient(0,384,1024,384); grd.addColorStop(0,「#00CED1」); (0.5,「yellow」) grd.addColorStop(1,「red」); – Akorna