changed previous code to this: int imgCenterX = (int) ((initx - joystick.get_joystickBg().getWidth()/2) - 50); int imgCenterY = (int) ((inity - joystick.get_joystickBg().getHeight()/2) - 50); int dx = imgCenterX - touchingPoint.x; int dy = imgCenterY - touchingPoint.y; float distance = FloatMath.sqrt(dx * dx + dy * dy);
// Out of bounds check. if (distance > 25) { touchingPoint.x *= 1f / distance; touchingPoint.y *= 1f / distance; this gives a weird effect where my "stick" which position is controlled by touchingpoint goes to 0,0, 90% of the time. Might help you to know that touchingPoint is a "Point", dont know if points are int or float. Thanks! -- 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