Page 1 of 1
On Screen Joysticks
Posted: Tue Mar 15, 2016 9:48 pm
by travismix1980
Just wondering if anyone had any idea on how to create on screen joysticks. I am working on a dual stick shooter that I would like to put on android and was just wondering if that was possible with Love2d and if anyone could point me in the direction of finding information on how to do this using Love2d . Thanks
Re: On Screen Joysticks
Posted: Wed Mar 16, 2016 8:39 am
by T-Bone
Doesn't sound too difficult to implement yourself. You'd need to keep track of where the user touches the screen, and from there find the closest virtual joystick center. If the distance is too far, you should probably discard the input. If not, then calculate the distance and direction (probably as a delta-x and delta-y vector, for efficiency), normalize the values, and then use them as input for the game.
Re: On Screen Joysticks
Posted: Wed Mar 16, 2016 12:36 pm
by zorg
Also, you can use the love.touch module to actually get the information you want about screen touches. I also recommend searching the projects subforum, since i do faintly remember that someone already created either a lib or a demo application showcasing touch-based on-screen controllers.