问题描述
好,我开始一个空白的地图,也就是512×512 = 262144个像素/位置。
OK I start with a blank map, which is 512x512 = 262144 pixels/locations.
我需要一种方法来有效地利用它的一些对象,然后能够找到自由空间的区域,这样以后更多种不同的对象可以被添加到这些自由区域。我不能找出最好的方式来存储这些数据,或算法来寻找自由的地方。
I need a way to efficiently draw some objects on it, and then be able to find the areas of free space, so that later more different objects can be added to these free areas. I cant figure out the best way to store this data, or algorithms to find the free areas.
我有一个工作的解决方案,但它永远了计算。我正在使用AS3,以免影响,这将是最好的解决方案。
I had a working solution, but it took forever to compute. I'm working with AS3, in case that impacts what would be the best solution.
什么建议?谢谢。
推荐答案
有很多方法处理位图的位图和的BitmapData类工作。
There is plenty of methods to work with bitmaps at Bitmap and BitmapData classes.
我从来没有做过这样的事情,但你可以尝试。我认为最好的办法是绘制对象地图。然后,使用方法bitmapData.getColorBoundsRect()来获取不自由的领域。这些AS3本地方法是非常,非常快!
I've never done anything like that, but you could try. I believe the best approach is to draw the objects at the map. Then, use the method bitmapData.getColorBoundsRect() to get the areas that are not free. These AS3 native methods are very, very fast!
下面的文档: HTTP ://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/BitmapData.html
干杯,CaioToOn!
Cheers,CaioToOn!
这篇关于如何有效地跟踪使用空间上的地图,对象和自由区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!