-4
似乎有像这样的其他问题,我想避免缓冲区和/或requestAnimationFrame()。Javascript画布闪烁
在最近的一个项目中,玩家闪烁但我找不到原因。你可以找到的jsfiddle项目:https://jsfiddle.net/90wjetLa/
function gameEngine() {
timer += 1;
timer = Math.round(timer);
// NEWSHOOT?
player.canShoot -= 1;
// MOVE:
movePlayer();
shootEngine(); // Schussbewegung & Treffer-Abfrage
// DRAW:
ctx.beginPath();
canvas.width = canvas.width;
ctx.beginPath();
ctx.fillStyle = 'black';
ctx.rect(0, 0, canvas.width, canvas.height);
ctx.fill();
drawField();
drawPlayer();
drawShoots();
setTimeout(gameEngine, 1000/30);
}
JavaScript中没有'const'。 – klenium
看看Mozilla开发者https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Statements/const? – user2531284
@ user2531284这就是es6。没有在每个浏览器中实现,还有一个大的警告... – Michelangelo