Flash: DisplayObject의transform/matrix의 잠재적 규칙, 작은 버그

1684 단어 transform
AS3에서 DisplayObject의transform/matrix를 사용하려면 먼저 clone을 꺼내서 변환한 다음에 값을 부여해야 DisplayObject에 영향을 주고 원래의 Matrix 조작에 직접적으로 영향을 줄 수 없습니다.
 
자세한 내용은 다음 코드를 참조하십시오.
 
var a:Sprite = new Sprite();
a.graphics.beginFill(0);
a.graphics.drawRect(0,0,100,100);
a.graphics.endFill();
a.x = a.y = 10;
addChild(a);
trace (a.transform.matrix );
 
var m:Matrix = a.transform.matrix .clone();
m.translate(30,30);
a.transform.matrix = m;
trace (a.x, a.y);
trace (a.transform.matrix );
 
m.translate(30,30);
a.transform.matrix = m;            //    Matrix   ,     
trace (a.x, a.y);
trace (a.transform.matrix);
 
a.transform.matrix .translate(30,30);             //         ,   a    
trace (a.x, a.y);
trace (a.transform.matrix );

 
출력:
 
(a=1, b=0, c=0, d=1, tx=10, ty=10)
40 40
(a=1, b=0, c=0, d=1, tx=40, ty=40)
70 70
(a=1, b=0, c=0, d=1, tx=70, ty=70)
70 70
(a=1, b=0, c=0, d=1, tx=70, ty=70)

좋은 웹페이지 즐겨찾기