I’d like to know if anybody has ever had a similar issue and more Importantly found a solution to the problem I have.
The problem: I made main menu button and it simply changes the scene to the main menu. It is for the pause screen, the level selection screen, the game over screen, and the beat level screens of my game. This function works just as expected it’s a simple condition and action as shown in the screenshot. No matter which scene I have these events on they do NOT work on mobile devices which are a Samsung tablet and Sony phone I tried. However when I preview the game on PC or export it as a .exe on PC the functionality works flawlessly just as would be expected.
I even made a new scene with just the event shown on the screenshot and it works on PC and doesn’t work on mobile just like before when I had
the main menu button event in other scenes.
When I have used the “cursor/touch is on” condition for other things such as exit game or game controls, and even buttons to select levels on the level selection screen, there is no problem on mobile or PC.
Do you have this anywhere in your events?
Yes I had that right at the beginning of my level 1 events, but only on level 1 events.
After reading your reply.
I put it on the other scene events such as game over, beat level, and select level scenes.
Now my main menu button seems to work fine in all this scenes It is in on mobile and PC.
Now I have Another issue
if I just use the condition “the cursor/touch is on” to change to my select level screen there is a problem. This problem is that the select level screen will naturally have lots of buttons to select levels that cover a large portion of the screen. So no matter where your finger was when touching the button that switched to the select level seen, The finger will inevitably touch and therefore press a button on the select level seen almost immediately after it loads.
Naturally the solution to this problem would be to use the condition “Left mouse button was released” under the “the cursor/touch is on” condition in the same condition block. This does indeed work on mobile and PC. The problem arises when the action “move mouse cursor when touching screen: no” is Present in my events. The buttons can be pressed and released, so essentially the buttons do nothing. However once the “move mouse cursor when touching screen: no” Action is disabled or deleted the buttons work perfectly on mobile and PC. However this then goes back to the problem of buttons inadvertently being pressed when the scene changes and the finger is still on a place on the screen where buttons are present in the new scene( this mainly applies to the select level scene).
I think you can solve this if you set the buttons to visible/hidden then check if click/touch is over button and button is visible then do this stuff.
Or adding a tween to button then at the begin of the scene set tween opacity form 0 to 255 and in your click/touch condition check if the button opacity is equal to 255
Can you please provide a screenshot(s) of the events you’re referring to?
Awesome thanks [UlisesFreitas]
I’ll try that and get back to you on that.
I just wanted to be sure since opacity, hide, visible are keywords in several conditions.
The GDevelop community is great.
My first question on the forums with such good responses.
Other posts are also quite civilized compared to other places on the web.
The way I understand your solution is as follows:
A button will only do its action (in this case changing scenes to main menu or other levels), if the cursor is on it and the opacity is 255.
The buttons will not work to change scenes even if the cursors is on them, if the opacity is not at 255.
Thus at the beginning of the scene the buttons’ opacities are at 0 effectively invisible, but tweening opacity increases opacity to 255 over the 2000ms set in the screenshots. So even if the finger was on a button right when the scene loaded it wouldn’t activate a button immediately since the opacity takes time to go from 0-255(2000ms in this case to be precise).
So am I wrong to keep the left mouse button was released condition in my events?
Any other mistakes you see please let me know.
When I exported and tried on mobile I saw the tweening effect go from 0-255 opacity but once at 255 opacity pressing my buttons didn’t do anything.
All is good now I removed the release left mouse button condition and added the opacity and tween events. Now buttons work on mobile too and there are no possibilities for accidental button presses when scenes are changed thanks again UlisesFreitas & MrMen.