0

I´m building a game that reads a bidimensional array so that it creates the map, but the walls are all separated from the corners and floors, each wall, each corner and each floor is an individual image, and this is consuming a lot of CPU, but I really want to create a random feeling of the map, and that´s why I´m using an image for each corner and wall.

I was thinking that maybe I could generate a texture built by merging 2 or more different textures, to enhance performance.

Does anyone know how that I could do that? Or maybe another solution? Does converting the images to PVR would make any difference?

Thanks

4

1 に答える 1

2

手始めに、TexturePacker などのツールで作成されたテクスチャ アトラスを使用して、できるだけ多くの「画像」を単一のアトラスにグループ化する必要があります。基本的に一度ロードすれば、リロードしなくても好きなだけスプライトを作成できます。PVR を使用すると、読み込みが高速になり、バンドル サイズにメリットがあります。

次に、特に地図の背景には、上記のスプライト シートで初期化した CCSpriteBatchNode を使用する必要があります。次に、タイルを作成するときに、スプライトを作成してバッチ ノードに追加するだけです。バッチ ノードをシーンに追加します。これの利点は、バッチ ノードに含まれるスプライト (タイル) の数に関係なく、すべて 1 回の GL 呼び出しで描画されることです。ここで、パフォーマンスの観点から最大のメリットが得られます。

最後に、シミュレーターで実行するときは FPS 情報に依存しないでください。シミュレーターはホストの GPU を利用せず、そのパフォーマンスはデバイスで得られるものよりも (はるかに) 低くなります。したがって、パフォーマンスに関する質問を投稿する前に、必ずデバイスで測定してください。

于 2013-04-22T12:06:33.100 に答える