How to make a touch event? (SOLVED)

I have tried to make touch events in Defold, but it doesn’t work. I have tried using the Touch Multi input, and I can’t get it to work. Basically, what I want is whenever I touch something for example a button, something happens. How can I do this on sprite and gui?

1 Like

For single touch (for e.g. clicking a button) you don’t use the multi-touch input. You use the mouse input like in this article. I haven’t done it on a sprite yet but this has worked fine for buttons:

Instead of mouse_press you input the ID you’ve set on the input page.

2 Likes

Oh! Thanks. I got it working now.

2 Likes

This works with GUI, but it doesn’t with sprites. When I try to make a click or touch event on a sprite, it does work, but not on JUST that sprite. If I click or touch any sprite it will cause the event. How can I make it so the event only happens on the sprite I want it to be? I haven’t been able to figure this out.

I also have a feeling its impossible to do that with sprites…

Hardly anything is impossible, but there is no built-in collision checking for sprites, since there are many ways to do it and it requires some amount of back-end setup.

There are a lot of threads on this topic, the best thing is to do a search: https://forum.defold.com/search?q=click%20on%20game%20object