[英]How to create a restart button for my snake game built in javascript?
var game = "play"; //This is the game variable
$("#Restart").click(function() { //Using the buttons
console.log("Restart Works");
gamerestart();
ctx.fill
});
function gamerestart(){
game = gamerestart;
ctx.fillStyle = '#00008b';
ctx.fillRect(0,0, canvas.width, canvas.height);
}
使用此方法使其他按钮正常工作,但重新启动一个按钮无效吗?
function gamerestart(){
game = gamerestart; //quotes?
ctx.fillStyle = '#00008b';
ctx.fillRect(0,0, canvas.width, canvas.height);
}
不应该是“ gamerestart”吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.