I’ve created a platformer where the player is running through a randomly generated level.
The level chunks are created in Tiled and loaded from .tmx files.
All of the level chunks use the same tileset and image for that tileset.
the tiles are 32x32
The level chunks are very small, e.i. 25x25
When the player gets near the end of the run, a new random level chunk is added to the end. Old level chunks are deleted when the player passes them.
The problem is that I get a huge drop in FPS every time a new level chunk is created and added to the end of the run.
I think it may be due to the fact that a TMXTiledMap creates a new texture atlas everytime the a new chunk loads? Shouldnt the texture atlas be reused since it is the exact same tile set?
this is what is written everytime a new tileset is created:
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
So my console window looks something like this as I run through the level and chunks are added to the end:
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [526] to [702].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [702] to [937].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [937] to [1250].
Cocos2d: cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [1250] to [1668].
e.t.c....
Any ideas on how to optimize this would be extremely appreciated.