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
419 stars 125 forks source link

setting stick X and Y to base X and Y in _onUp when stationarybase: true #33

Open ssugar opened 8 years ago

ssugar commented 8 years ago

When using a stationary base, stickX and stickY are not reset to anything in the _onUp function, so deltaX and deltaY keep returning the last value prior to _onUp being called.

Setting stickX = baseX and stickY = baseY when stationarybase is not false (as in my pull request) fixes this.

erichlof commented 8 years ago

@ssugar Thank you noticing this and for the fix! It was an oversight on my part. I was the one a while back who added the stationary base stuff.
@jeromeetienne This fix looks good to me. btw, long time no hear, hope you are doing well Jerome! :-)

Thanks again @ssugar

ssugar commented 8 years ago

No worries. Happy to contribute. Virtualkeyboard.js is a cool library. Thanks to you @erichlof and @jeromeetienne

I'll also send through another commit for a prototype I wrote that returns the angle of the stick based on the dx dy between the stick and the base.

0 degress is the exact right of the base, moves counterclockwise through to 360 degrees which takes you back to the exact right of the base.

Maybe I should have created this as separate pull request? If so, let me know and I'll try to fix this up.

Cheers

erichlof commented 8 years ago

@ssugar
Sounds good to me, (just add the angle stuff to this PR) although @jeromeetienne has the final say because this is his library. Yes, virtualjoystick is a great tool, it is my go-to library when I need touch interactions in Javascript. Thanks for your contributions:-)