gpt4 book ai didi

javascript - 乒乓球比赛获胜后不会出现文字

转载 作者:行者123 更新时间:2023-12-03 01:40:08 25 4
gpt4 key购买 nike

function drawEverything(){
//next line blacks out screen
colorRect(0,0, canvas.width,canvas.height,'black');
if(showingWinScreen){
canvasContext.fillStyle = white;
if(player1Score >= winningScore){
canvasContext.fillText("Left Player won!",350,200);
}else if(player2Score >=winningScore){
canvasContext.fillText("Right Player won!",350,200)
}

canvasContext.fillText( 'click to continue', 350,500)
return;
}

//this is left player paddle
colorRect(0,paddle1Y,paddleThick,PADDLE_HEIGHT,'white');

//this is right player paddle
colorRect(canvas.width- paddleThick,paddle2Y,paddleThick,PADDLE_HEIGHT,'white');

//next line draws a ball
colorCircle(ballX,ballY,10,'white');

canvasContext.fillText( player1Score, 100,100);
canvasContext.fillText( player2Score, 700,100)
}

所以我正在编写一个乒乓球游戏,我正在尝试创建它,以便一旦有人赢得游戏,就会显示文本来说明哪个玩家获胜。然而,一旦有人赢得了比赛,我看到的就是黑屏。我想我已经将问题范围缩小到了这段代码,但我不确定出了什么问题。有人可以告诉我出了什么问题吗?

最佳答案

 canvasContext.fillStyle = white;

白色应该是这样的字符串:

 canvasContext.fillStyle = 'white';

参见Examples供引用。

关于javascript - 乒乓球比赛获胜后不会出现文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50884419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com