Skip to content
Advertisement

How to track a touch on the screen

I want to write a penalty shootout application, now I have set up the background and added the ball and the goalkeeper to the map. How do I make it so that when I tap on the screen, the ball follows my touch on the screen. How to do this? How to track the touch on the screen and enter the ball after my touch.

MainActivity.kt

JavaScript

activity_main.xml

JavaScript

Screen app

Advertisement

Answer

I found the answer to my question, you need to use onTouchListener. My code looks like this:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement