I am an experienced programmer with C++/C# trying to get into the android game design world.
Using Java in Eclipse.
There are a bazillion tutorials on how to move a single object by tracking a touch on an entire screen, but how do i track touch events on many individual objects randomly on screen?
For starters i wanted to write a class that would be instantiated multiple times and held in an arraylist. Each is drawn to a random position on a fullscreen, SurfaceView. Easy stuff so far…
But for the life of me i cannot find out how to drag any of these objects around!!
I have an activity that uses a custom view (extends SurfaceView). Instantiates a GameBoard class that handles game board screen drawing. the GameBoard class also holds/draws an ArrayList of gameCharacters that draw fine on the screen, but need touch control.
Im at my wits end, any help out there?
I wrote a top-down shooter (Akari) which doesn’t drag the objects around, but uses their location for collision detection.
In my SurfaceView I call theThread.touchEventType(x, y). The thread goes through the objects (in your case, the array), and checks if they match. In the case of a match, it would return a value associated with the object, and all MotionEvent.ACTION_MOVEMENT actions before MotionEvent.ACTION_UP are done on that object.
Hope this helps. If you need any sample code let me know.