I know this is more of a general programming question, but my Android friends here have always been helpful. I am trying to make an image move from one part of the screen to a position the user touches, as a constant speed. I don't know the best way to go about doing this and the way I have been trying to get to work is taxing my brain too much.
I have been using geometry to calculate slope, then using Sin * movement speed to calculate the difference in X,Y coordinates. This is the code I'm looking at: TouchX = V.TX; (This is the touch event coordinates TouchY = V.TY; ) Slope = (TouchY - V.CurY) / (TouchX - V.CurX); (this figures out the slope of the line to the touch point) DegreeSlopeY = Math.atan(Slope); DegreeSlopeY = Math.abs(DegreeSlopeY); (this is so that I can calculate the direction the image should travel along the slope) DegreeSlopeX = (90.0000000000000 - DegreeSlopeY); NewY = (mMoveSpeed * Math.sin(DegreeSlopeY)); (This calculates the shift in Y axis for the image) NewX = (mMoveSpeed * Math.sin(DegreeSlopeX)); (This calculates the shift in X axis for the image) if(TouchX < V.CenterX) NewX = -NewX; (This is to finish calculating the correct X axis direction to travel) if(TouchY < V.CenterY) NewY = -NewY; (This is to finish calculating the correct X axis direction to travel) The problem that I'm having is the image is veering way of course when traveling in Y heavy paths. When traveling horizontally it works almost perfect. I know there is probably an easier way though I don't know how to use a lot of things (like OpenGLES) so if your advice is to use a different method please link a tutorial for that method if you know of one. Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en