Buttons on android?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ismaelmosciski
Prole
Posts: 1
Joined: Fri Jul 08, 2022 12:51 am

Buttons on android?

Post by ismaelmosciski »

Hi,
I'm planning on making a top down shooter game on android for android but I can't seem to get the buttons right.

I used GUI libraries like "SUIT" but it's doesn't support hold or I can't configure how. If you know how to make button (doesn't need to be complex just supports hold movement) please help me out. If you want to join me on my "On Android For Android" just tell me.

Thanks in advance.
User avatar
darkfrei
Party member
Posts: 1181
Joined: Sat Feb 08, 2020 11:09 pm

Re: Buttons on android?

Post by darkfrei »

Are you need just GUI buttons?
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: Buttons on android?

Post by EngineerSmith »

It's pretty much the same as PC; but using different callbacks

https://gist.github.com/EngineerSmith/7 ... ec05c7c095

I threw together a basic example. It is a little over engineered; but by handing all input in one file it is much easier to track and trace where things are going wrong with touch if there is ever a problem.

It supports taps (0.2 seconds) and held down buttons (bottom button resets the top tap button)

With a top down shooter maybe a better path would be to use an on-screen joystick which is just a some simple vector math for movement (although a held down button is probably wanted for things like firing a weapon)

This is only meant to really be an example as there are some issues with it; mainly on things like overlapping buttons. It doesn't include a way to scale buttons either as it's just an example for input (but should be pretty simple with this system as you tell it where the button is and can reset the callback to a new area if the screen resizes or something else, etc. etc.).
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: Buttons on android?

Post by Gunroar:Cannon() »

The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 59 guests