0

我正在使用 actionscript 3.0,但我不明白是什么给了我们 Transform 类?

 import flash.geom.Matrix;

 var mat1:Matrix = new Matrix();
 mat1.identity();
 mat1.rotate(Math.PI/4);
 mat1.scale(2,2);
 mat1.translate(10,20);

我可以做的事情:

var shape:Shape = new Shape();
shape.x = 50; //the same as the translate tx
shape.y = 50; //the same as the translate ty
shape.rotation = 45; // the same as the rotate
shape.scaleX = 20; // the same as the scale X in Matrix object
shape.scaleY = 30; // the same as the scale Y in Matrix object

或者问题是:做同样事情的 Matrix 对象方法或 Shape、MovieClip、Sprite 方法有什么区别???,我真的不明白,也许我遗漏了什么?

4

1 回答 1

2

对于一个矩阵运算可能更快,

在几秒钟内,您可以轻松地对矩阵执行多项操作,然后轻松地将其应用于多个不同的对象,您还可以使用矩阵倾斜您的点,但不能直接使用形状。这就是线性变换的全部内容。

维基百科中的线性地图

注意变换点方法。

至于你的第二个问题,这取决于你使用它的目的,如果你想在几个相似的点上执行相同的转换,你应该考虑构建一个矩阵,然后在每个点上应用它。

于 2012-07-05T14:10:16.280 回答