在计算机和 iPhone 上运行良好,但在 Galaxy S3 上,移动的块会留下随机清理的痕迹。我该如何解决?
http://curtastic.com/test7.html
踪迹每秒消失一次(按原样清除)。
<html>
<head>
<meta name="viewport" content="width=device-width" />
</head>
<body style='margin:0;width:640px;'>
<div id=fps></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var block;
var angle=0;
var fpsFrames = 0;
var fpsTime = 0;
function gameLoop() {
var now = new Date();
fpsFrames++;
if (now - fpsTime >= 1000) {
$('#fps').html("FPS: "+fpsFrames);
fpsFrames = 0;
fpsTime = now;
}
block.x += 3;
if (block.x >= $(window).width()-50) {
block.x = 0;
}
block.canvas.css('left', block.x);
block.canvas.css('top', block.y);
}
$(document).ready(function() {
$("body").append("<div id=block style='position:absolute;width:33px;height:33px;background:green' class=block></div>")
block = [];
block.canvas = $('#block');
block.x = 0;
block.y = 55;
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
(function animloop() {
requestAnimFrame(animloop);
gameLoop();
})();
});
</script>
</body>
</html>