博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Flash:DisplayObject的transform/matrix的潜规则、小bug
阅读量:4322 次
发布时间:2019-06-06

本文共 850 字,大约阅读时间需要 2 分钟。

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)

转载于:https://www.cnblogs.com/kenkofox/p/3305244.html

你可能感兴趣的文章
Vue基础安装(精华)
查看>>
Git 提交修改内容和查看被修改的内容
查看>>
PAT - 1008. 数组元素循环右移问题 (20)
查看>>
请求出现 Nginx 413 Request Entity Too Large错误的解决方法
查看>>
配置php_memcache访问网站的步骤
查看>>
hibernate的id生成策略
查看>>
树莓派3B+学习笔记:5、安装vim
查看>>
[Spfa][bfs] Jzoj P5781 秘密通道
查看>>
企业帐号进行IPA的打包、分发、下载安装的详细流程(转载)
查看>>
《项目架构那点儿事》——快速构建Junit用例
查看>>
{"errmsg":"invalid weapp pagepath hint: [IunP8a07243949]","errcode":40165}微信的坑
查看>>
DB2V9.5数据库使用pdf
查看>>
Java Bigdecimal使用
查看>>
SQL注入之绕过WAF和Filter
查看>>
jquery validate使用方法
查看>>
DataNode 工作机制
查看>>
windows系统下安装MySQL
查看>>
错误提示总结
查看>>
实验二+070+胡阳洋
查看>>
Linux IPC实践(3) --具名FIFO
查看>>