Hi all,
Another week has passed, and I'm very nearly finished my first cocos2d project. Everything was running fine until I started introducing other scenes (like a menu scene). Now I'm getting some choppy performance - but only if I launch my main game scene from my main menu scene. I think the way I've implemented the main game scene is perhaps not a particularly efficient approach. Here's how I'm currently doing things:
My GameScene contains a whole bunch of animated characters running around the screen. These are frequently removed and others replace them, so there is no runaway build-up of sprites at any one time. Each of these sprites is actually a Layer subclass, containing an AtlastSpriteManager, and an AtlasSprite (I started this last week in 0.82 - not had a chance to re work it for 0.99 yet). Each instance of this sprite can be one of 3 randomly selected types (ie, they use one of 3 different sprite sheets).
This was working fine until I started launching the GameScene from my MainMenuScene. Now the whole thing intermittently freezes for a split second every time a new sprite is spawned (I think).
Is it possible that whatever image caching was taking place before is now not happening? How should I be structuring things?
I did try creating a single AtlasSpriteManager property for each sprite sheet in my GameScene, and then passing a reference to the GameScene into the sprite objects, and sticking all the sprites in to these shared AtlasSpriteManagers, but after a few spawns the game would crash.
Any advice would be great, as I'm just making this up as I go along, and would love to know how other people are doing things!
Cheers,
Dunc.