Android - Is it possible to have dynamically moving clickable objects in a view
For the purposes of say game development, is it possible to set up a view and create a class that extends button or implements clickable or something. Im trying to figure out the best way to handle screen clicks on moving objects onscreen and right now Im drawing everything in a canvas which inturn is drawn to a view but I cant make individual bitmaps representing objects clickable. So before I throw out a lot of work already and try for it does anyone know if its possible to have dynamically moving objects within a view that can independently handle screen clicks.
Add an OnTouchListener to your view (the one that that draws all your objects on the canvas), and in the onTouch(View v, MotionEvent event), get the coordinates of the event: int x = event.getX(); int y = event.getY(); Then loop through your objects that you draw and see if these coordinates are on that objects current area, if so, you know that it has been clicked.
How to display data in listview from sqlite database in android
Persistent permissions to non-SAF content
Pass touch event from an overlaying View down to underlying TabLayout
How to detect if token is expired or not registred firebase FCM notification on app server?
How to color a period of days in a CalendarView in android? [on hold]
How to make file manager type back navigation with onClick action.
How to have transparent viewGroup while creating a dialog?
Set default home screen Android(Rooted Device)
Get Image from Gallery with Intent
Overwrite File with Zeros Android
Push notification not delivered to my phone when app is not running?
iterator for expandablelistview
Evaluating a c++ expression during debugging in android studio
UnityPlayer.UnitySendMessage not working from a non-UnityPlayerActivity
Marshmallow runtime permission
Unable to generate unassigned apk file