欲绕其中心而非左上角旋转此物体。 在code是这样的:
I want this object to rotate around its center rather than the top left corner. The code looks like this:
switch (event.keyCode)
{
case 37:
car.rotation = -90;
car.x -= 5;
break;
所以,当我preSS左键,车向左转,但因为它是现在它跳了一下,因为它围绕旋转的右上角。
So when i press the left key, the car turns left but as it is now it jumps up a bit because its rotating around the top corner.
感谢
下面将围绕中心旋转:
public function rotateAroundCenter(object:DisplayObject, angleDegrees:Number):void {
if (object.rotation == angleDegrees) {
return;
}
var matrix:Matrix = object.transform.matrix;
var rect:Rectangle = object.getBounds(object.parent);
matrix.translate(-(rect.left + (rect.width / 2)), -(rect.top + (rect.height / 2)));
matrix.rotate((angleDegrees / 180) * Math.PI);
matrix.translate(rect.left + (rect.width / 2), rect.top + (rect.height / 2));
object.transform.matrix = matrix;
object.rotation = Math.round(object.rotation);
}
有翻译对象的中心到0,0然后转动,然后将其翻译回
It translates the center of the object to 0,0 then rotate it and then translate it back.
上一篇:使用C#在Active Directory中检查用户名是否存在是否存在、用户名、Active、Directory
下一篇:如何获得Active Directory属性不能再由UserPrincipal类psented $ P $再由、如何获得、属性、Active