Touch object but not when dragging camera

Hi,

I’m using the DragCameraWithPointer extension to allow me to scroll horizontally on a layer. This layer has clickable objects. Initially when dragging and the touch/cursor touched an object, that object changed scene. I only want this when the camera is not moving/being dragged.

I’ve tried this:

But now it does not trigger the touch event, as I am assuming that any touch events triggers the camera drag action thus also setting scroll = 1.

I’ve tried moving the events in different order to no luck. Has anyone done this, or can guide/point me to a way in fixing my “code”?

Thanks
Mike

Any ideas with this? Surely it’s just a simple fix?

If you use a button object or this behavior:
https://wiki.gdevelop.io/gdevelop5/extensions/button-states/
you can check if no button is pressed.

Thanks, it has helped a bit. There are still instances where it confused dragging the camera to a button press to change level - but it’s better than it was. I’ll still tweak it until I get it right, I might just have to resort to a next/previous buttons instead of dragging.

Maybe you can use a timer to figure out how much time had passed since that “touch” begun till it’s release, if it’s something like 0.5 seconds or less then it’s a tap and it triggers the button, if it’s more than that then it don’t triggers the button and it just drag the camera.

Many apps and games works like this on mobile.

1 Like

thanks!
I was searching about the same problem and you gave a great solution, and it worked!

1 Like

Here is how I did it.
With this method, there is 100% no active button when scroll.
If your screen is only scroll on X or Y, then remove the other for more easy click able.

1 Like

This answer has been a massive help, thank you very much.