Alright, so I change the previous code to this:
int imgCenterX = initx - joystick.get_joystickBg().getWidth()/2
- 50;
int imgCenterY = inity -
joystick.get_joystickBg().getHeight()/2 - 50;
Point imgCenter = new Point(imgCenterX, imgCenterY);
int dx = touchingPoint.x - imgCenter.x;
int dy = touchingPoint.y - imgCenter.y;
float distance = FloatMath.sqrt(dx * dx + dy * dy);
Log.d(TAG, "destance HERE: " + distance);
// Out of bounds check.
final float radius = 25.0f;
if (distance > radius) {
touchingPoint.x = imgCenter.x + (int)(dx * radius /
distance);
touchingPoint.y = imgCenter.y + (int)(dy * radius /
distance);
}
atleast now it dosnt change its pos to 0,0, now it just gets stuck 0,x
somewhere, so this code didnt work either. Might help to now that
touchinPoint is set through event.getX() and event.getY, but you probably
understood that.
I've had this problem for over 2 weeks, so if there is anything I can do to
make it easier for you to help me please let me know.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en