左キーを押してキャンバス上で何かを動かそうとしています。
$(document).ready(function () {
var ctx = document.getElementById('canvas').getContext('2d');
var img = new Image();
img.onload = function(){
ctx.drawImage(img,0,0); // draw the image at the right coords
ctx.drawImage(img,110,110); // draw the image at the right coords
ctx.save();
};
img.src = 'tiles/processed/1_grass.png'; // Set source path
function draw() {
ctx.translate(20,0);
};
draw();
draw();
draw();
$(document).keydown(function(e) {
if (e.keyCode == 37) {
draw();
};
});
});
これで、3 つの draw(); が機能しているように見えますが、関数内の機能は機能していません。
キャンバスの概念を完全に見逃していますか (本質的に静的であり、常に完全に再描画する必要があります)、それとも何か間違っていますか?
(ps .: Jquery も使用しています)
乾杯!