-1
我正在按照教程来填充颜色的画布。没有着色发生。这可能是因为函数update()和函数draw()是空的?帆布不被着色
<!DOCTYPE html>
<html>
<head>
<title>Basic Example</title>
<script src="BasicExample.js">
</script>
</head>
<body>
<div id="gameArea">
<canvas id="myCanvas" width="800" height="480"></canvas>
</div>
</body>
</html>
JavaScript文件
var canvas = undefined;
var canvasContext = undefined;
function start() {
canvas = document.getElementById("myCanvas");
canvasContext = canvas.getContext("2d");
gameLoop();
}
document.addEventListener('DOMContentLoaded', start);
fuction update() {
}
function draw() {
}
function gameLoop() {
canvasContext.fillStyle = "blue";
canvasContext.fillRect(0, 0, canvas.width, canvas.height);
update();
draw();
window.setTimeout(gameLoop, 100/60);
}
错字:'功能'。使用[浏览器控制台(开发工具)](https://webmasters.stackexchange.com/q/8525)(点击'F12')并读取任何错误。 – Xufox