There is a button in the first scene in my game and when this button is pressed, the transition to the 2nd scene is made. There is no problem with this, but there is a different button in the same place in the 2nd scene. When you switch to the 2nd scene, it automatically presses the button in the same place.
(i am making this game for android phones and the solution should work for phones :))
Hard to understand but I think adding some conditions to the press condition will help, for instance in my games I always check the opacity of the button, what I do is to set the button opacity to 0 at the begin of the scene then in a condition check if button opacity is < 255 then button opacity += 255*Timedelta(), so in all my press button events I do
If mouse/touch button
button opacity = 255
Trigger Once
— Then do my actions.
This way if a button is pressed at the very begin of the scene it will not be triggered until it reach the 255 opacity which it takes a second or less depending on the Timedelta
Begin
Always running
Button start pressed
3 possible ways around this :
-
use Mouse Released rather than Mouse Clicked (from memory this’ll work for touch as well).
-
In the beginning of scene 2, check if mouse is down or touch is held, and set a scene boolean variable to indicate this. Reset it to false when touch or mouse is no longer down. Only allow clicking on the button based on this variable.
-
Similar to #2, but use a global boolean variable when the button in scene 1 is pressed, and set it to false when there’s no touch or mouse is released in scene 2.
thanks, i solved the problem very similar to method 3