if I change imgPos to (initx - 100, inity - 100) it works perfectly. But I
really need to find a better way to calculate the middle, Ill keep working
on this cus that shouldnt be to hard. Thank you so so so much for helping
me with this, spent endless hours on it. So thank you!
>
> You could try following (if I understood your coordinate system
> correctly);
>
> Point imgPos = new Point(initx - 50, inity - 50);
> Point imgCenter = new Point(joystick.get__joystickBg().getWidth() / 2,
> joystick.get_joystickBg().getHeight() / 2);
> int dx = touchingPoint.x - imgPos.x - imgCenter.x;
> int dy = touchingPoint.y - imgPos.y - imgCenter.y;
>
> float distance = FloatMath.sqrt(dx * dx + dy * dy);
> Log.d(TAG, "destance HERE: " + imgCenterX + " : " + touchingPoint.x);
>
> // Out of bounds check.
> final float radius = 25.0f;
> if (distance > radius) {
> touchingPoint.x = imgPos.x + imgCenter.x + (int)(dx * radius /
> distance);
> touchingPoint.y = imgPos.y + imgCenter.y + (int)(dy * radius /
> distance);
> }
>
> I can't try this out right now but hope that this provides proper distance
> calculations only.
>
> --
> H
>
>
--
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