Ask here your questions to get help using GDevelop.
By steveang9999
#69968 Yes, it did work for first time, after that it becomes like that. always returning the position of touch < center of button background.

So i wondered and try to test on the example you made on mobile, it works exactly like this also. Always moving left when you click anywhere on button background. But weirdly if i preview on laptop, it works for your example. Although i copy the exact same code from yours, mine returns the same result, always going to the left
User avatar
By ddabrahim
#69969 It works for me :?
Do you change anything at all? You name the object differently that's for sure. As I mentioned I call it ButtonBg, on your screenshot I see JoyStickBgm.

I honestly don't know. The example I made works on all my touch devices, if it works at first and then it doesn't it must be something on your end but I have no idea what.

Could you upload the project so I can have look and compare to my project?
User avatar
By ddabrahim
#69973 You are checking the position of the touch on the base layer but the ArrowButtonsBg is on the "GUI" layer.
So make sure you check position of the touch on the GUI layer.
gui.png
gui.png (20.85 KiB) Viewed 208 times


I was forget to mention this in the example, I'll update the example with a comment mentioning this.
By steveang9999
#69987 hmm yeah, but even if i change the layer of button to base layer, it still gives me the same result, always moving the character to the left side even if the touch is > than centre of button.
User avatar
By ddabrahim
#69988
hmm yeah, but even if i change the layer of button to base layer, it still gives me the same result

You don't want the button to be on the base layer, because then if the character move to the right, you leave the button behind as you move the camera on the layer to follow the player.
You want to check touch on the GUI layer and keep the button on the GUI layer.

It works for me. It is maybe your device then.
All I do and did again just to be sure,
1. unzip the archive you have uploaded.
2. open the project in GD5
3. in BOTH conditions to check position of touch, change layer to "GUI"
4. save and export

Done. It works on my side on my touch devices :?

If you mean it doesn't work with the mouse on PC that is because you are checking position of the touch and not the mouse.

If you are testing this on a Windows tablet maybe the multi touch events does not work on Windows? Could anyone confirm this with a Windows touch device please?

If you are testing this in the browser on an android or ios device, you may need to hard refresh the browser to make sure the game update in the cache.

In case you are exporting to APK and install on your device then I have no idea why it doesn't work for you, hope someone can figure this out.
I would be curious what is going on, on your end :|
Anyone?
By steveang9999
#69999 hmm, ok let me try one more time on exporting the whole apk to an android phone and see if this problem still exist. It is very weird that it only works on your side and i have about 3 smart phone (both android and iphone), all of them gives me the same result, means that whenever i touch the button, whatever location it always return value < than the centre of the button, thus always walking to the left side.
User avatar
By ddabrahim
#70009 Yeah it is weird. Would be nice if a 3rd party could confirm if it doesn't work. Since it works for me I can't figure out what the problem is. :(
By GyGabor
#70127 Hello,

I'm glad to join the forum :)
The solution works. If not used a multitouch. If you first touch the screen elsewhere after that, the second touch is not treated separately. The JoysticktouchID alwways 0. Now I'm making an 360° analog joystick control and I couldn't fix this error. That's why I use draggable object behavior. And it works like a dream. I'll try to upload the working version to the forum in 1-2 days. :D
Sorry for my bad English. ;)
Gabor