change the old code into 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);
Log.d(TAG, "destance HERE: " + distance);
// Out of bounds check.
if (distance > 25) {
touchingPoint.x *= 1f / distance;
touchingPoint.y *= 1f / distance;
}
this gives a weird result where 90% of the time the "stick" will set its
position to 0,0 when I try to use it.
Might be important to know that this is how I draw my stick:
canvas.drawBitmap(joystick.get_joystick(),
controls.touchingPoint.x - 13, controls.touchingPoint.y - 13,
null);
PS: sorry for all the removed posts, cant find an edit-button :S
--
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