ippa / jaws

Jaws - HTML5 canvas javascript 2D Game Framework
https://jawsjs.ippa.se
GNU Lesser General Public License v3.0
363 stars 75 forks source link

jaws bug? #49

Closed cobagithub closed 12 years ago

cobagithub commented 12 years ago

Hi I'm new in html 5. I'm actually new in game development.

I noticed that when the player is moving, if you change the browser tab or opening something that make the page suddenly lose focus, when you get back to the page, the player will keep moving and hard to be stopped.

In this page http://jawsjs.com/jawsjs/examples/example3.html if you move left(keep pressing left arrow), then suddenly change to other tab and got back to the example tab, you'll notice that the robot will keep moving to the left.

ippa commented 12 years ago

I think this is because that jaws detects the left-press so jaws.pressed("left") keeps returns true.. but it doesn't detect the keyup cause it happens in the other tab.

Hm, this could probably be prevented by resetting any all jaws key-states on the onblur event ...

ippa commented 12 years ago

Fixed in https://github.com/ippa/jaws/commit/131c7752255420b70908c221af94f50282b60da5