I’m trying to make a bitmap rotate and point towards the mouse but I get strange results:
Video: http://www.truploader.com/view/993341
The mouse isn’t visible it does rotate, however it doesn’t rotate to the tip of the mouse point.
Code:
/**
* Rotates the object based on a point
*/
public void setRotation(float x, float y)
{
float XDistance = this.xPos - x;
float YDistance = this.yPos - y;
float Radians = (float) Math.atan2(YDistance, XDistance);
this.degrees = Math.round((Radians*180/Math.PI));
this.moveObject();
this.r.setRotate(this.degrees, this.picture.getWidth() / 2, this.picture.getHeight()); //origin of the base
// this.r.setRotate(this.degrees, this.picture.getWidth() / 2, this.picture.getHeight() / 2);
}
Mouse position is x, and y. Anyone any ideas?
Where do you get the “mouse position”? I guess you take it from a MotionEvent, so notice this coordinates are relative to the target View origin.