Can't move with scripts - HTML5
So I've been trying to create a game with Adobe
Animate and HTML5 canvas just for fun.
Anyways I can't seem to get player movement to work.
I've tried using:
var canvas = document.getElementById("canvas");
canvas.addEventListener("keydown", doKeyDown, true);
function doKeyDown(e) {
var playerSpeed = 100;
//W Key
if (e.keyCode == 87) {
this.player.y-=playerSpeed;
}
//S Key
if (e.keyCode == 83) {
this.player.y+=playerSpeed;
}
//A Key
if (e.keyCode == 65) {
this.player.x-=playerSpeed;
}
//D Key
if (e.keyCode == 68) {
this.player.x+=playerSpeed;
}
}And it didn't work, so if you can help please do.
Thanks in advance.
