Cocos 2D 2.8.2 beta: TMX tile map tests with huge maps.

While developing using Cocos 2D (0.8.2 beta) on iPhone i faced some huge performaces problems loading

a map of 9472 tiles (4096px x 592px, 16x16pixels tiles).

The loading process took about 1.30 secs on an iPhone 3GS…

I’ve done some tests changing % value in row 208 of TMXTiledMap.m:

float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ?

TESTS——————————————————————————

test 1 (original, capacity is 35% of #tiles): capacity = totalNumberOfTiles *0.35f +1-> loading time: 1.15 secs (4 TextureAtlas changing operations)

test 2 (capacity is 100% of #tiles): capacity = totalNumberOfTiles +1 -> loading time: 1.25 secs (no TextureAtlas changing operations)

test 3 (capacity is 50% of #tiles): capacity = totalNumberOfTiles *0.50f +1 -> loading time: 1.20 secs (some TextureAtlas changing operations)

test 4 (capacity is only 10% of #tiles): capacity = totalNumberOfTiles *0.10f +1 -> loading time: 1.10 secs (8 TextureAtlas changing operations)

/TESTS——————————————————————————

The strangeness is that setting to max value the capacity decrease performances! So it seems that the performances bottleneck isn’t in memory copy operations but somewhere else. Probably the performance problem is due to the use of AtlasSprite to contain every tile.

The only solution for now is to load only a subset of tiles and replace then when the character moves a some amount of pixels/tiles: in this way the loading process decreased to about 5 secs (or less).

UPDATED: after my post on the Cocos2D forum (http://www.cocos2d-iphone.org/forum/topic/2165?replies=12#post-14895) “riq” about this issue, a developer of the project, patched in a day this problem and now to load of these huge maps takes ONLY 1.5secs!!!!

The pacthed version is available downloading from the google SVN repository.

ps. I don’t know why noone pointed this problem, but now all developers will be really happy of this patch version!

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.