#Best Approach for On-Screen Buttons and Joystick for a Mobile Game?

1 messages · Page 1 of 1 (latest)

rare snow
#

With GameMaker recently making mobile exports free I'm currently working on porting a fangame I'm developing to Mobile platforms. The game currently runs great on Mobile if a Bluetooth gamepad is connected but I'd like to add on-screen controls as an option for players.

GameMaker has an official tutorial for on-screen controls and I tried following it but it seems flawed (https://gamemaker.io/en/tutorials/multi-touch-joystick). Their tutorial relies on the Draw GUI event, but the joystick in it is a physical object. The Draw GUI event only allows you to draw sprites, not manage instanced objects, so this joysticks location doesn't update as the game's camera moves. The understanding I have now is that I'd need to take one of the two following approaches:

Make the joystick and buttons physical objects. Have them be persistent (so they exist across rooms) and manually update their position in the "End Step" event.

Draw the joystick and button sprites on the GUI layer. Use another object to check if certain areas of the UI are being touched and whether or not a button/joystick is being drawn in this area and should be clicked as a result.

I'm not sure if either option is necessarily better. I also admit I may have misunderstood the official GM article on the topic but I did try following along with it directly and it didn't seem to work. The joystick wouldn't move with my camera and while the base was rendering, the actual "stick" wasn't, implying there may have been some alignment issues going on.

#

I'm at work right now so I might not be super responsive but on reflection I realized I didn't try downloading and testing the code included with the official GM tutorial. I tried incorporating the tutorial with my game directly but something could've gone wonky as a result. I'm going to give that a shot as soon as I go home.