欢迎来到天天文库
浏览记录
ID:33580017
大小:2.80 MB
页数:33页
时间:2019-02-27
《flash_game_optimization》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Flash游戏优化技巧黄竣平台技术经理junhuang@adobe.comwww.fans8.com©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.2SmoothingGamePlay=BetterGame©2010AdobeSystemsIncorporated.AllRightsReserv
2、ed.AdobeConfidential.3©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.4帧频CPU内存©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.5代码优化帧频不够?图像优化CPU消耗太高?内存优化内存占用过多?显示优化⋯⋯©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeCo
3、nfidential.6Flash游戏中ActionScript代码优化©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.7Flash游戏中的ActionScript代码优化脚本运行速度的检测充分运用FlashPlayer新功能•Vector类与Array类varstarted:Number=getTimer();•新的绘图API……执行代码•处理像素的新方法……varrunTime=getTimer()-started;•事
4、件捕获和冒泡•其他©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.8Flash游戏中的ActionScript代码优化•Vector类与Array类FlashPlayer10引入了Vector类,其读写访问速度比Array类更快varcoordinates:Vector.varcoordinates:Array=newArray();=newVector.();varstarted:Numbe
5、r=getTimer();varstarted:Number=getTimer();for(vari:int=0;i<300000;i++)for(vari:int=0;i<300000;i++){{coordinates[i]=coordinates[i]=Math.random()*1024;Math.random()*1024;}}trace(getTimer()-started);trace(getTimer()-started);//output:107//output:72尽可能尝试使用Vect
6、or对象API,因为它们的运行速度可能更快©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.9Flash游戏中的ActionScript代码优化•新的绘图APIFlashPlayer10提供了一个新的绘图API,使用它可获得更好的代码执行性能。此新绘图API包含下列方法:•drawPath()•drawGraphicsData()•drawTriangles()此新的API不提供显示性能改进,但可以大大减少必须编写的代码行数。
7、代码行越少,ActionScript执行性能越好。©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.10Flash游戏中的ActionScript代码优化•处理像素的新方法FlashPlayer10中引入的了快速绘制及读取像素的方式•setVector()•getVector()•如果使用setPixel()或setPixel32(),请使用lock()和unlock()•减少遍历像素的次数•配合Vector类来提高像素处理速
8、度©2010AdobeSystemsIncorporated.AllRightsReserved.AdobeConfidential.11Flash游戏中的ActionScript代码优化•事件捕获和冒泡ActionScript3.0中的事件模型引入了事件捕获和事件冒泡的概念。for(vari:int=0;i
此文档下载收益归作者所有
点击更多查看相关文章~~