我試圖朝着鼠標的位圖旋轉和角度,但我得到了奇怪的結果:的Android編程位圖的旋轉
視頻:http://www.truploader.com/view/993341
鼠標是不可見它不旋轉,但它不會旋轉到鼠標尖端。
代碼:
/**
* 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);
}
鼠標位置爲x,和y。任何任何想法?