I canโt explain why the first line in the "buttonHandler" function below will not work, after this statement the canvas will not be displayed. But the first line of the "startPlay" function is the same, and this displays the canvas! If anyone can understand why from this section of code, please let me know ..
thank.
I tried this on Chrome and Firefox with the same results.
function buttonHandler(){
canvas.style.display = "block";
var menuDisplay = document.getElementById("menuDisplay");
menuDisplay.style.display = "none";
drawingSurface.font = readyDisplay.font;
drawingSurface.fillStyle = readyDisplay.fillStyle;
drawingSurface.textBaseline = readyDisplay.textBaseline;
drawingSurface.fillText(readyDisplay.text, readyDisplay.x, readyDisplay.y);
window.setTimeout("startPlay()", 3000);
}
function startPlay(){
canvas.style.display = "block";
gameOver.style.display = "none";
balls=[];
for(var i=0;i < sprites.length; i++){
var thisSprite = sprites[i];
if(thisSprite !== cup){
removeObject(thisSprite, sprites);
}
}
score = 0;
totalSeconds = 5;
gameState = PLAYING;
drawingSurface.clearRect(0, 0, canvas.width, canvas.height);
window.setTimeout("tick()", 1000);
timeToBall = Math.floor(Math.random() * 250) + 50;
update();
}
Paris source
share