jeromeetienne / virtualjoystick.js

a virtual joystick library to emulate a joystick on touch screen in javascript
http://jeromeetienne.github.com/virtualjoystick.js/examples/basic.html
MIT License
417 stars 125 forks source link

Simulate joystick click #29

Open maxsoulard opened 9 years ago

maxsoulard commented 9 years ago

Simulates joystick click by calculating if the virtual stick position is within the canvas circle. basic example also updated to test the center position.

jeromeetienne commented 9 years ago

what about using current callbacks instead ? like here

It is more flexible and let the user chooses the behavior it want for the click

maxsoulard commented 9 years ago

I am not sure to fully understand what you are saying. As you probably saw, the code I wrote allow to determine if the stick is inside or outside the joystick base circle. I am using that in my app to simulate a stick click (as on physical controllers). Maybe my pull request naming is not well chosen. Or maybe I didn't understand at all what you proposed :)