android


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.

Related Links

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

Categories

HOME
shell
facebook-oauth
gdb
components
sublimetext
vscode-extensions
cq5
hugo
gluon-mobile
pkcs#11
g++
pcl-crypto
text-mining
mxgraph
jxl
chargify
ember-cli
easeljs
bulletphysics
fractions
event-flow
recurring-events
cognos-bi
kodi
fstream
dynamic-jasper
installscript
ideascript
kill
ogc
laravel-elixir
levenshtein-distance
oracle-service-bus
knime
rfc3339
puredata
dynamic-linq
proget
robomongo
chai-as-promised
globalize
rserve
qtranslate
sandcastle
vcloud-director-rest-api
cronexpression
avspeechsynthesizer
thread-sleep
httpruntime.cache
jnlua
google-books
rubaxa-sortable
ember-cli-rails
avahi
bufferedinputstream
android-broadcast
deform
contrast
wcm
build-script
radiant
high-resolution
eclipse-kepler
unit-of-work
mantle
swfobject
alice
android-holo-everywhere
listactivity
umra
strsep
xui
codebase
cac
office-2007
opml
sifr
qtabbar
lobo-cobra
java1.4
dsoframer
contentpresenter

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App