Hello, I am making a simple game for class on an Android phone in which you can change a ball's position by touch. I had it working in Processing by simply using mouse position. In Android, I am using the gesture scanner and corresponding methods for various gestures, but I can't figure out the exact way to pull in the coordinates of the touch method into the ball object's x/y coordinates. I hope that I am making sense! Thanks so much.
A:
If your ball is an image in an ImageView
, then you know the starting position of this ImageView object; save it in prevPosition
variable. Whenever you encounter a touch event you will get the coordinates of the location where touch has taken place(currPosition
), move your ball from prev location(prevPosition
) to this new location and update your prevPosition
variable(prevPosition=currPosition
).
Hope this helps!!
cooltechnomax
2010-08-24 07:58:29