AS3瓦片地图渲染(与1000的砖) [英] AS3 tile map rendering (with 1000's of tiles)

查看:470
本文介绍了AS3瓦片地图渲染(与1000的砖)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是第一关,我会说,这里的环境是ActionScript 3.0中(IDE:Flashbuilder)随着德裕框架

Just first off I'll say that the context here is Actionscript 3.0 (IDE: Flashbuilder) along with the Starling Framework.

所以,我想创建一个瓷砖地图可能被用于一些成熟的或类似的东西。

So, I want to create a Tile Map that could be used for a platformer or something similar.

我想8x8像素的瓦片上的800×600像素的阶段,我遇到的问题是,我不知道如何添加这些7500+瓷砖对象在舞台上不大幅降低帧率。

I want to use 8x8 pixel tiles on an 800x600 pixel stage, and the problem I am having is that I don't know how to add these 7500+ tile objects to the stage without dramatically reducing the framerate.

我发现,在性能上的下降来自添加的每个瓦片的阶段,而不是从初始化每个瓷砖对象。

I've found that the drop in performance comes from adding each tile to the stage, not from initializing each Tile object.

我知道我不会给太多具体的信息,但我要问的是,如果有一个标准化的方式来吸引数千静态对象走上舞台没有性能损失。我觉得有一种方法,我只是还没有找到它。

I know I'm not giving much specific information, but what I'm asking for is if there is a standardized way to draw thousands of static objects onto the stage without a loss of performance. I feel like there is a way, and I just have yet to find it.

更新:

在所有你的帮助,我已经发现了什么似乎是一个很好的解决方案。起初,我想要实现艾米的解决方案,使用copyPixels(),并绘制()做一个大的位图数据的全图,然后渲染到屏幕上。然后,不过,我想知道是否有相当于这个八哥,因为一切都将是非常简单的,如果我没得混德裕本机Flash。

After all of your kind help, I have found what seems to be a great solution. At first I wanted to implement Amy's solution, using copyPixels() and draw() to make one large bitmap data for the whole map and then render that to the screen. Then, though, I wanted to know if there was a Starling equivalent to this, because everything would be so much simpler if I didn't have to mix Starling with Native Flash.

感谢Amy,我再次看着椋鸟的渲染纹理类的更多一点,并且发现使用它的drawBundled()和画()的方法,我可以很容易地绘制所有的砖到一个渲染纹理,然后把渲染纹理成影像(八哥的图像类),然后只是图像添加到屏幕上。

Thanks to Amy again, I looked into Starling's RenderTexture class a bit more, and found that using it's "drawBundled()" and "draw()" methods, I could easily draw all of the tiles into a RenderTexture, and then put the RenderTexture into an Image (Starling's Image Class) and then just add that Image to the screen.

该解决方案是一个比傻慢的解决方案,我尝试过,与扁平化精灵和这样快一百万倍。它的速度更快无论是在它的初始化的时候,大家似乎都在帧率没有下降,而渲染纹理的图像出现在屏幕上。

That solution is a million times faster than the silly slow solutions I tried before, with flattening sprites and such. Its faster both in it's initialization time and there seems to be no drop in framerate while the renderTexture's Image is on the screen.

有一件事我要测试与此是,如果它是很容易在游戏中更新瓦的显卡。也就是说,如果从源(或东西)和草瓦水US $ p $垫必须成为一个水瓦,那份渲染纹理,它的形象是能够改变自己的外貌没有某种滞后穗或性能打嗝。我测试了这一点很快。

The one thing I want to test with this is if it is easy to update the graphics of a tile during the gameplay. Say, if water spreads from a source (or something) and a "Grass" tile had to become a "Water" tile, would the RenderTexture and it's image be able to change their appearance without some sort of lag spike or performance hiccup. I will test this out soon.

感谢大家的帮助!

推荐答案

不要添加许多对象的阶段。相反,创建一个BitmpaData你的舞台的大小,并使用copyPixels()或绘制()来绘制在上面。 这里有一个文章,应该让你开始。然后,你可以把你那个岗位学到的概念,你需要做的,这不是涉及具体学什么(flashandmath.com有很多很好的教程约像素处理)

Don't add that many objects to the stage. Instead, create a BitmpaData the size of your stage and use copyPixels() or draw() to draw onto it. Here's an article that should get you started. You can then take the concepts you learned in that post and learn anything specific you need to do that's not covered (flashandmath.com has a lot of good tutorials about pixel manipulation)

这篇关于AS3瓦片地图渲染(与1000的砖)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆