Question

I have some sprite sheets I am using for a game I am making, and am looking for some help on memory management with relation to sprite sheets.

I currently have 8 Sprite sheets (2048x2048), each representing one of my playable characters abilities and movements. At the moment, I add them to the cache once the user has selected that character. I also have 1 more sprite sheet (2048x2048) which contains sprites for items in the game (things like grenades/weapons/ground objects).

At a maximum there will be 4 Characters + the other Item sprite sheet active at any time. My question is, from a memory stand point, is this too much to use at any one time? Would I be better suited using 1 Massive sprite sheet to lower I/O calls? When should I load them? Can I manually unload them to improve performance?

Thanks!

Was it helpful?

Solution

You should read this very interesting article about memory optimization with cocos2d: http://www.learn-cocos2d.com/2012/11/optimize-memory-usage-bundle-size-cocos2d-app/

Of course you can manually unload textures when you want (see CCTextureCache and CCSpriteFrameCache) but from my experience it's usually better to preload as much as you can and not worry about unloading unless it actually raises memory issues.

Then I'd say that the fewer sprite sheets the better, but given that the maximum supported texture size is 2048×2048 for some devices like iphone 3GS and iphone 4, I'd recommend not using "one massive" sprite sheet (unless you can keep it within this 2048×2048 size)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top