Mobile Button Not Working

I’m trying to make a game that you can toggle between mouse/touch and key controls, but I’m having a problem with one button. When I open the game through the Menu Scene and enter the Game Scene, the Up Button (SonarButtonUp, positioned above the player) doesn’t respond to touch. It plays once and then it doesn’t respond again.

Strangely, when I open the game from the Game Scene, the Up Button responds anywhere I touch, even when I press the other buttons.

What could be causing this?


The conditions The cursor is on object does what it says and only checks if the cursor is on the object (hover), so the event will trigger regardless if it’s pressed or not.

I believe the reason the button is working only once is because on touchscreen devices, what you don’t see is that when you touch the screen, the cursor actually moves to the position of the touch and stays there until you press somewhere else. So the cursor stays on the button and the event will only trigger once.

To fix this, you can add the behavior “Button states” to the button.
Then replace “The cursor is on Button” with “Button is pressed” (you get this condition from the added behavior).

1 Like

I don’t know if that’s the case. I’ve tested the game both on my ipad and with the cursor on my desktop. The left, right, and down buttons work perfectly. It’s only the up button that doesn’t respond. The animation for the up button will play once at the beginning of the scene and then it won’t play again, even if I move the cursor off or on it. It’s strange, I thought I programmed them all the same way.

I’m open to trying the behaviours as a last resort. I thought it could be a good challenge to see how much of a game I can program from scratch.

Okay, I finally figured out why the Up button wasn’t working and you’re NOT going to believe it!

The problem was the Angle Action. I have the Up button’s angle set to 0. I just changed that to 1… and now it works!

I figured that it might have something to do with the angle actions because that was the one thing that was different between the four buttons - but I didn’t think that could’ve been the solution!

I think I laughed like a maniac for a few seconds after I realized this, haha :rofl:

Weird problem and solution! It’s hard to guess the exact reason without debugging. But hey, if it works it works!

1 Like

True dat.

I actually don’t know how to debug with GDevelop. Do you know how they do it?