Hi
Im struggling to get the player/image move from one level to another on the map using one button (forward). From level 1-1 to 1-2 everything works great, but if i add another level, the player/image skips the level in between??? The same goes for the back button. Does someone here have any tips on how I can achieve this? My code looks like this:
Any tips is greatly appreciated
Okay so first off, I see that one of the actions is being repeated.
The variable of FadeToLevel53 = 1 : change opacity of FadeToLevel53 set to 0
It skips because the events are all activating in a âchainâ as long as your mouse is on the button.
Try adding a (if âxâ button released) which, in theory should only activate the actions when the button is released and only trigger once when those conditions are true.
Because the program constantly checks for the conditions of all events, so as soon as your mouse is on Right Button, the actions are done but the system then also checks for the other event and then activates it because your mouse is still on the button.
However, do note that this has a tendency to not work. The program activates both states of the button when those conditions are true.
For example:
If x is true do y.
Left mouse button released
If y is true do x
Left mouse button released
So:
X is true so then y is done but as soos as y becomes true the system also activates the second event since it is also true in those few milliseconds that the âbuttonâ released state is true.
Sorry that I donât have a full proof fix for your problem, since I also struggle with the exact same thing. All I could do is Identify the problem. I have no fix, sorry
a click/touch released condition should help indeed
Here, itâs easily solved by changing the event order.
If right arrow increases 1, put the events in decreasing order, to make sure the key released condition wonât trigger in cascade.
In other cases like you mention, you should use a variable check.
See: How to toggle states using Variables - GDevelop documentation
Ty!
*They should really remove 20 character limitationđ©
Wow! So simple yet so effective. Never would have thought about that
It exists exactly because you shouldnât just write âthank youâ, as it bloats the topic with nonconstructive comments. If you want to show appreciation for someones answer, the like system was designed for that. Consider reading the rules.
Makes sense. Just a pain when all that you want to do is say ty. But I understand.
I redid the codes and changed almost everything in the condition and actions. I added the
-click/touch released- condition together with decreasing the order of the variable item like you suggested and it made it work without the player skipping levels. Fantastic!
But is there something in the code that Im missing, because it only works when testing/running the game on a pc, and not on a phone? Is it because of the -left mouse button was released- condition?
No, it shouldnât be related. Left click and touch share the same action.
Did you set up that action somewhere?
Awesome!!! -Move mouse cursor when touching screen- was set to: no. Changing it to : yes ,made everything work like a charm on the phone also