
用到的 canvas 技巧
function draw(delta) {
 totalSeconds += delta;
 var vx = 100; // the background scrolls with a speed of 100 pixels/sec
 var numImages = Math.ceil(canvas.width / img.width) + 1;
 var xpos = totalSeconds * vx % img.width;
 context.save();
 context.translate(-xpos, 0);
 for (var i = 0; i < numImages; i++) {
     context.drawImage(img, i * img.width, 0);
 }
 context.restore();
}
final
Panning and scrolling background images using the canvas element
若有錯誤的觀念或是資料授權有問題,再煩請通知我,謝謝