I'm having a problem with easelJS, I have a function that listens for keyboard input but it does not update the variables according to the keys i hit. I placed a console.log inside the different cases and it logs fine but for some reason it does update variables. I think I may not be understanding how it works. here is my code
function handleKeyDown(event) {
switch(event.keyCode) {
case 16:
sonicSpeed = 15;
sonicState = 2;
console.log("Shift Key Pressed");
break;
case 65:
sonicState = 1;
sonicDirectionXN = true;
break;
case 68:
sonicState = 1;
sonicDirectionXP = true;
break;
case 87:
sonicState = 1;
sonicDirectionYN = true;
break;
case 83:
sonicState = 1;
sonicDirectionYP = true;
break;
}
}
if (sonicState == 0) {
var sonic1 = new createjs.Sprite(spriteSheet1);
}
else if (sonicState == 1) {
var sonic1 = new createjs.Sprite(spriteSheet2);
}
else if (sonicState == 2) {
var sonic1 = new createjs.Sprite(spriteSheet3);
}