2017-04-25 23 views
0
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); 
    } 

使用此方法使其他按鈕工作,但重新啓動一個不工作?如何爲我的蛇遊戲創建一個重新啓動按鈕內置JavaScript?

+1

什麼是遊戲?你有沒有可用的遊戲?爲什麼'game = gamerestart'工作?你真的想把這個函數本身分配給遊戲,還是你的意思是'game =「gamerestart」'?顯示一些實際的代碼! –

回答

0
function gamerestart(){ 
    game = gamerestart; //quotes? 
    ctx.fillStyle = '#00008b'; 
    ctx.fillRect(0,0, canvas.width, canvas.height); 
} 

它不應該是「gamerestart」嗎?

相關問題