これは私の jsfiddle です: http://jsfiddle.net/yKvuK/6/
if (keydown.right) {
characterImg.src = 'http://pixenate.com/pixenate//cache/photo_e2094a30725ccd74a6d889648d34343b.jpg';
character.CurentPos++;
character.x += character.speed;
if (character.x > CanvasWidth - character.width) { // make the character keep walking even if he step outside the canvas
character.x = 0;
}
}
if (keydown.up) {
characterImg.src = "http://pixenate.com/pixenate//cache/photo_1_5ef90294cd2afeb4486dedd663cfd872.jpg";
character.y -= character.speed;
if (character.y < 0) {
character.y = 0;
}
character.CurentPos++;
}
if (keydown.down) { //going down
characterImg.src = "http://pixenate.com/pixenate//cache/photo_1_ff6712ddd80b138f1865eb4937622d1b.jpg";
character.CurentPos++;
character.y += character.speed;
if (character.y > CanvasHeight - character.height) {
character.y = CanvasHeight - character.height;
}
}
キャラクターを上下に移動しようとすると問題が発生します。誰か助けてください。