On Screen Joysticks

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Posts: 1
Joined: Tue Mar 15, 2016 9:41 pm

On Screen Joysticks

Post by travismix1980 » Tue Mar 15, 2016 9:48 pm

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

User avatar
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: On Screen Joysticks

Post by T-Bone » Wed Mar 16, 2016 8:39 am

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.

User avatar
Party member
Posts: 2868
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary

Re: On Screen Joysticks

Post by zorg » Wed Mar 16, 2016 12:36 pm

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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests