ActionScript 2的大瓦为基础的地图创建滞后地图、基础、ActionScript

2023-09-09 21:24:33 作者:听、这一季雨落

我不知道该怎么去闪光灯使用ActionScript 2是创建大型,瓷砖为主图的最佳途径。

I'm wondering what the best way to go about creating large, tile-based maps in flash with actionscript 2 would be.

使用我目前的code,超过35x35任何地图(1225影片剪辑)开始落后。该地图是从一个简单的多维动阵,例如创建。

With my current code, any maps over 35x35 (1225 movieclips) start to lag. The maps are created from a simple multi-demensional array, eg.

var map = [[95,23,25,23,16,25],[95,23,25,23,16,25],[95,23,25,23,16,25]];

该程序简单地创建一个平铺的影片剪辑,进入到相应的框架,并将相对于球员的位置的瓷砖。每瓦有一个特性,那就是'步行的',这是真或假,用来确定玩家可以在上面行走与否。这些砖是持有人的影片剪辑的孩子的。当玩家移动时,保持器的movieclip移动(和包含在它然而许多瓦片)。

The program simply creates a movieclip of a tile, goes to the appropriate frame and places the tile relative to the player's location. Each tile has one property, that is 'walkable' which is either true or false which determines if the player can walk on it or not. These tile are childs of a holder movieclip. When the players moves, the holder movieclip is moved(and however many tiles that are contained in it).

什么是减少对大型地图的滞后最好的方法是什么?

What would be the best way to reduce the lag on large-scale maps?

推荐答案

如果在大地图中只有一小部分是可见的时间,我只会造成孩子影片剪辑瓷砖瓷砖当前可见,然后添加/删除它们视口四处移动。

If only a small portion of the large map is visible at a time, I would only create the child movieclip tiles for tiles that are currently visible, and then add/remove them as the viewport moves around.

在另一方面,如果你显示一次整个事情,你可能需要使用图形化地复制所有的砖到一个大的影片剪辑的的BitmapData 类。然后你就可以删除影片剪辑的瓷砖,这样的Flash只需要滚动一个大的影片剪辑。

On the other hand, if you're displaying the whole thing at once, you'll probably need to graphically copy all of the tiles onto a single large movieclip using the BitmapData class. Then you can remove the movieclip tiles so that Flash only has to scroll one large movieclip.

根据你的砖,你也可以尝试设置的cacheAsBitmap 来真正与分配 opaqueBackground 上所有的影片剪辑参与。

Depending on what your tiles are, you can also experiment with setting cacheAsBitmap to true along with assigning opaqueBackground on all the movieclips involved.