有幾種方法可以完成此操作。首先是使用變換矩陣。 下面是我用圍繞在時尚點旋轉對象的功能:
*您需要導入fl.motion.MatrixTransformer,如果不使用的FlashPro你可以在這裏:https://code.google.com/p/artitem-as3/source/browse/trunk/ArtItem/src/fl/motion/MatrixTransformer.as?r=3
/**
* Rotates a displayObject around the passed local point.
* @param displayObj
* @param relativeDegrees - the relative amount of degrees to rotate the object
* @param point - a local point to rotate the object around, if null, center of bounding box will be used.
*/
public static function rotateAroundPoint(displayObj:DisplayObject, relativeDegrees:Number, point:Point = null):void {
var m:Matrix = displayObj.transform.matrix.clone();
if (!point) {
//default is center of bounding box
var r:Rectangle = displayObj.getBounds(displayObj);
point = new Point(r.x + (r.width * .5), r.y + (r.height * .5));
}
MatrixTransformer.rotateAroundInternalPoint(m, point.x, point.y, relativeDegrees);
displayObj.transform.matrix = m;
}
另一個更偷懶的方法來做到這一點,是使用假父對象,只是旋轉是:
var dummy:Sprite = new Sprite();
dummy.addChild(yourObjectToRotate);
//this effectively makes the anchor point of dummy in the center, so when you rotate it it rotate from the center.
yourObjectToRotate.x = -(yourObjectToRotate.width * .5);
yourObjectToRotate.y = -(yourObjectToRotate.height * .5);
dummy.rotation = 90;
這可能是你已經盡力了,但你改變的scaleX而不是寬度的實驗?我不確定這是否會導致數據透視表現得更好 – 2013-05-06 19:40:41