Hi, I'm making an RPG game right now. I want to move my character with arrows. It works right now. But I want to change the image by right-clicking. Right now, when I press the right arrow with this code:
function rightArrowPressed() {
var element = document.getElementById("image1").src = "/img/run_1.png";
element = document.getElementById("image1");
element.style.left = parseInt(element.style.left) + 5 + 'px';
}
Changing the image to run_1.pngant is saved. Than just the image glides in one pose. How to change the image again when I press the right arrow?
HTML
<img id="image1" src="{{Auth::user()->char_image}}" style="position:absolute;left:0; top:0;height: 45px; image-rendering: -webkit-optimize-contrast;">
source
share