Lots of movie clips make flash lags?
i created a game that has 96 still movieclips and seven more movieclips that basically move horizontally. The lag starts to rise if i add more and more moving movieclips. The game loop just basically, increment the x coordinate of the movieclips, so i don't think i have problems in the game loop.
Is it normal the flash will lag once it has exceeded certain number of movieclips?? if it's normal, what do you suggest to increase the game's performance?
anyway, this is the update method from the game loop:
public function update():void
{
开发者_运维问答 //cek kondisi untuk melakukan spawn char
spawnChar();
//cek kondisi untuk melakukan spawn stand(stand diisi oleh pedangang di zona)
spawnStand();
//cek tiap char untuk tiap kondisi sekaligus assign depth yg sesuai;
for (var i:int=0; i<mArrForeObjects.length; i++)
{
mArrForeObjects[i].update();
if (mArrForeObjects[i] is Char && mArrForeObjects[i].x > mWorld.MAP_WIDTH * Tile.TILE_WIDTH || mArrForeObjects[i].x < - mArrForeObjects[i].width || mArrForeObjects[i].y > mWorld.MAP_HEIGHT * Tile.TILE_HEIGHT + mArrForeObjects[i].height || mArrForeObjects[i].y < 0)
{
//jika di luar peta, hapus char ini
delChar(i);
}
}
}
thx
If you're just moving the display objects on the x-axis, you can try setting cacheAsBitmap to true to increase performance. Or, you can try redrawing bitmaps of each object from a shared bitmapData object. Here is an interesting article with a performance test.
i've solved the lag by loading picture as BitmapData and copypixel it to the screen reference : http://www.8bitrocket.com/2008/7/2/Tutorial-AS3-The-basics-of-tile-sheet-animation-or-blitting/
精彩评论