ocanvas

Javascript Variable not passing through ocanvas function and for loop

纵然是瞬间 提交于 2019-12-13 22:06:34
问题 I'm having an issue with a variable not being passed through an ocanvas function. it appears that the variable is changing inside the function but isn't making it outside the function. here is my code: sonicSpeed2 = 0; sonicState2 = 0; canvas.bind("keypress", function () { var keys = canvas.keyboard.getKeysDown(); var x; sonicSpeed2 = 4; for (x = keys.length; x > 0; x--) { if (keys[x-1] == 16 && keys.length > 1) { sonicSpeed2 = 15; sonicState2 = 2; } if (keys[x-1] == 65) { sonicState2 = 1;