【发布时间】:2018-12-18 12:09:44
【问题描述】:
所以我对 js-canvas-animation 中的 clearRect 有疑问。此问题仅在 Android API 16 上发生,并且仅在动画重新启动时发生。
我在动画中使用setInterval()(这里是简化代码)
function start() {
clearInterval(animationInterval);
x = 0;
canvas = document.getElementById("animationCanvas");
ctx = canvas.getContext("2d");
animationInterval = setInterval(func, 30);
}
function func() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillRect(halfWidth - x, 0, 250, 150);
x += extensionStep;
}
它看起来像一个海岸。但是每次,当我使用帮助启动功能重新启动动画时,在新动画下我都会看到上一帧的上一帧动画。我已经在尝试beginPath()、save、stroke。我检查了所有关于 SO 的问题,什么也没有。
如何清除动画下的背景?
【问题讨论】:
标签: javascript android canvas webview