【发布时间】:2014-06-14 21:51:47
【问题描述】:
我有一个简单的 as3 代码块,它从 MC 复制像素并使用它们显示在几个对象上(就像一个现场拼图,哪个部分在舞台上)。然而,从我读过的和聚集在一起,如果我想让性能达到最大值,我应该使用 Starling。但!从帖子中我发现,如果 RenderTexture (.draw) 真的是一个更好的解决方案,我不太明白。
而且由于代码相当简单(而且我对 Starling 很陌生),我能问一下它(下面的代码)是如何翻译成 Starling 的吗?
private var movingPicture:MovieClip = new RollerCoaster();
private var _sourceBitmapData:BitmapData = new BitmapData(500, 500);
private var elements:Array = [];
private function onFrame( ev:Event )
{
_sourceBitmapData.lock();
_sourceBitmapData.draw( movingPicture );
for(var r:int = 0; r < row; r++)
{
for(var c:int = 0; c < col; c++)
{
elements[r][c].bmd.copyPixels(_sourceBitmapData, new Rectangle( (c * elementW ), ( r * elementH ), elementW, elementH), myPoint);
}
}
_sourceBitmapData.unlock();
}
//elements[r][c] is a MovieClip and it has some vars in, that can be used, like :
//public var bmd:BitmapData;
//public var bm:Bitmap;
//PS: I never add **movingPicture** to the stage, I just use it to copy from it
【问题讨论】:
标签: actionscript-3 optimization starling-framework