2

我会直奔主题

我需要绘制一个大尺寸的矩形(大约 5k 像素的宽度和高度,可能更多)

this.graphics.beginFill(0x555555,1);
this.graphics.drawRect(0, 0, 5000, 5000);

现在我知道,一开始,它需要时间来生成这么大的矩形,但即使在之后,fps 也非常低,特别是如果舞台上有其他东西在移动,

我需要这个来玩游戏(它是地面),有没有更好的简单方法来做到这一点?

谢谢

4

3 回答 3

3

如果您的应用程序的窗口仅为 800x600,则无需绘制 5000x5000 的图像。您可以做的是拥有 5000x5000 位图数据,然后将其子矩形复制到窗口上。bitmapData.copyPixels应该让你这样做,而且速度非常快。

于 2013-03-06T15:05:24.577 回答
2

您可以将一个大背景替换为多个小背景,并根据当前视图位置更改其位置。例如,dims 为 5000 的矩形可以拆分为 25 个“tile”,宽度和高度为 1000 px。您可以有两个将保存当前图块的 MovieClip。您需要 2 个持有人 - 一个持有当前视图,第二个持有将在当前瓦片离开屏幕时变得可见的瓦片。

于 2013-03-06T13:50:46.873 回答
0

Assuming the game area is not scaled and you will scroll the game, you won´t display the whole 5000 px rectangle, so you can create a ground with the same size of the stage area and place it in a layer that moves along the visible area. Just a simple parallax.

One layer with the one color ground. Other layer with things moving over it.

Anyway you should give more information about the game. Vector graphics? Bitmaps? game area scalable?

于 2013-03-06T16:10:52.983 回答