Closed dsyenket closed 6 years ago
I'm afraid I won't be much help on this one. Your code looks like it should work, so I'm not sure why there would be a bit of lag when the player touches the screen.
do you have other ways to make it work on mobile devices?
If you want to have the canvas scale with the size of the device, I have a codepen showing how to do that with css. For this game, the one button touch should be enough for controls. I can't think of anything else that is needed for mobile.
Hi, i think this issue can be closed.
Hi, do you have any idea on how to make this game works on mobile device? I found out that the action was attached specifically to the space bar key code which doesn't work on mobile device. The codes below is what I used now but it doesn't work smoothly, when the player jumps there is a bit of lag. canvas.addEventListener('touchstart', function(e) { KEY_STATUS[KEY_CODES[32]] = true; e.preventDefault(); }, false);
canvas.addEventListener('touchend', function(e) { KEY_STATUS[KEY_CODES[32]] = false; e.preventDefault(); }, false);