Problem creating touch controls for mobile platform game


#1

Hi all,
i’ve created simple controls for a touch platform game. When i touch and hold left/right and then jump the player jump left/right. But when i release the jump, still holding the right/left control, the player stops moving…why? :confused:

touch-problem.png


#2

I don’t know is this working or helping anything but check the example “Multitouch.gdg” in GDevelop example folder.


#3

Hi,

The “Touch or Left mouse button is down” only works with single touch. So, when you release one finger, the condition stops from being true and your player stops moving. Just remove this condition (from all the events) and it will work (“Cursor/touch is on XXX” already tests if the touch is on one object, with multitouch support).


#4

Thanks Victor, but removing “Touch or Left mouse button is down” the action never stops. For example if i press left and put the finger off the screen the player continues moving in that direction…!


#5

Yo!

I have the same problem…


#6

I forgot that you also need to disable the “moving cursor with touch” feature to allow the multitouch to work. This can be achieved by adding the “deactivate moving mouse cursor with touches” (“Mouse and touch” category) at the beginning of the scene.

You can see an example of touch controls by creating a new project with the “HTML5 > Platformer” template.


#7

Great! Thank you very very much! :slight_smile:


#8

Thank you so much​:heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart:


#9

Thanks! Now in 2020. This has helped me, but a new issue arose. My character moves and jumps by clicking on the in game gui ive made (left, right, jump buttons) but now it also disables the touch and drag mechanics in the in- game objects. With the former solution. I can move other game objects around and my player can run and jump (albeit constantly/infinitely). Is this a mobile bug? I can either let my player run in one direction constantly and jump constantly until i tap on the screen or push jump again to stop the player (and allow me to tap and move in game objects around) or let my game be a simple platformer with tap object to move disabled.


#10

This topic is 10 years old. The users in this post are probably inactive by now and the answers outdated. Please create your own topic to ask a question about this and if you want to link that old topic but don’t necropost please :wink: