thanks for taking the time to help me.
It ALMOST works now, the stick acts lke imgCenterY and imgCenterX is a bit
further down then they really are. I know I'm using the right positions cus
if I draw a circle at that position it gets drawn in the exact middle of my
joystickBG.
this is how I add the stick: canvas.drawBitmap(joystick.
get_joystick(), touchingPoint.x - 13, touchingPoint.y - 13,null);
this is how I add the joystickBG:
canvas.drawBitmap(joystick.get_joystickBg(), initx - 50, inity - 50, null);
and this is the changed code:
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: " + imgCenterX + " : " +
touchingPoint.x);
// 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);
}
--
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