Page 1 of 1

Buttons on android?

Posted: Fri Jul 08, 2022 12:53 am
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.

Re: Buttons on android?

Posted: Fri Jul 08, 2022 7:14 am
by darkfrei
Are you need just GUI buttons?

Re: Buttons on android?

Posted: Fri Jul 08, 2022 12:22 pm
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.).

Re: Buttons on android?

Posted: Fri Jul 08, 2022 6:38 pm
by Gunroar:Cannon()