Touchscreen Game

I’m making a platform game, I’ve used the multitouch example to trying to fix my problem.
The problem is that, if I’m touching the right/left button and the jump button at the same time my character won’t jump or move.
It seems like it doesn’t detect both touches at the same time

You’ll need to get and use TouchId to use multitouch properly. Using “touch/mouse is over” only works for one touch.

I’m using this code.
Multitouch is in the second screen

Why are you using a repeat for each marker in the first screen shot? Because those event conditions will never be true - if the marker is on the LaunchRoundButton object, then it won’t be on either of the other two buttons (GDevelop will only check for the marker you’re repeating for, not all of the ones on the screen).

Remove that repeat for each marker (remember to drag the “Layer “UI” is visible” event to the left first), because all you care about is if there’s a marker on each of the buttons.

1 Like

Thank you! I’ll change that part when I come back at home. I’m sure it’ll work after this change!!

It doesn’t work even after this change

Can you screen shot your changes?

And does this GDevelop multitouch example work on the device that your project isn’t working on?

I’ve removed the “for each object of marker” on top of" UI is visibile".
Plus the markers are working because when I touch two different part of the screen I can see two different markers. It seems like the game doesn’t “read” two different touches made at the same time.

Those “button press” events in the latest screen shot are 3rd tier subevents. What are the two parent events that haven’t been included in the screen snip?

Also, that last subevent is redundent - it’s catered for by the previous “button press” events.

These two events are on the top, plus I’ve removed the redundent event too.

Did the solution work?

Those events are not the parent events. They’re sibling events. They’re on the same level as “Layer 'UI' is visible”.

The “Layer 'UI' is visible” event is a parent event of “Marker is on ....Button” events. If you collapse a parent event, it’s children are hidden

The red lines below lead up to the parent events. What are those events?

Also, these two events are redundant - they have no actions :

Oh sorry, the parent events are the animations.

No unfortunately, I’m still trying to fix it myself too, but it seems so hard to find a solution

I think you’ll need to refactor your events.There are quite a few that can be grouped or made subevents off a conditional event. For example, you’ve got a lot of them with “UI layer is visible” as a condition. You can create one event with that condition, and then have all the UI visible related events as subevents.

Also, you logic isn’t right. For example, this event :

I suspect you want to pause the animation if there are no markers on the arrow buttons. However, this won’t work when ther are multiple touches on the screen.

For example, take the BottomArrowButton and 2 touches. If it only has one of the markers on it, and the other marker is not on it, and the condition is true, even though there is a marker on it, because there is a marker that’s not on the button.

What you should do is create 5 boolean scene variables (one for each button). In an unconditional event, set these 5 variables to false. Then create 5 more events, one for each button. If a marker is on the button, then set the corresponding boolean variable to true.

You then use the boolean variable in your other events to check if a marker is (or is not) on the button.

Something along the lines of :

Hi, the player is unable to move with these changes. Also, in your screen you wrote false instead of true in two cases

I added a “at the beggining” in the first event, and 5 new events to set the booleans false if the maker isn’t inside the buttons. But the original problem is still there. The player can’t jump and move if you click two buttons at the same time

Those aren’t the only changes you have to make. It’s just an example of how you need to check if a marker is, or is not, on a button. You’ll need to make wholesale changes to all your events, as in rewrite or reorder them.

Well spotted, sorry about that. That’s what copy and paste can do.

That won’t work. Think about what that does - it checks for markers on the buttons once when the scene starts, and then that’s it. No more checks again. You don’t want that.

You want it being checked every frame, every time the events are processed. They have to be actions of an unconditional event.

1 Like

Hi! I’ve changed the system behind the movements of my character. Now I’m using the condition “touch is on object” and “left key of the mouse is pressed”. Now everything works! Thank you for helping me during these days!!

Ok, though that won’t work with multi touch.

However, if it satisfies your requirements, then excellent, it’s great to see you’ve worked out a solution.

1 Like