Limit to spritesheet loading

My game includes a large number of characters and variations, which will grow (think Pokemon). I have a way to update assets, but I’m worried about the collection aspect. With 12 character spritesheets (and growing) with 17 characters on each, the player’s personal collection tab can have 50 characters in a grid (5x10 buttons in a scrollview) which may end up using all 12 spritesheets and could eventually bloom to 50 spritesheets … in theory, as the selection grows.

I’ve tested in the simulator, up to 21 spritesheets and coordinate map files. Is there a limit anymore? Is it device specific?

I used to use an old bit of code to try to do dynamic spritesheet loading, but widgets require loaded sheets. I would hope the engine would be able to manage them dynamically as well.

function unrequire(m) package.loaded[m] = nil rawset(\_G, m, nil) -- Search for the shared library handle in the registry and erase it local registry = debug.getregistry() local nMatches, mKey, mt = 0, nil, registry['\_LOADLIB'] for key, ud in pairs(registry) do if type(key) == 'string' and type(ud) == 'userdata' and getmetatable(ud) == mt and string.find(key, "LOADLIB: .\*" .. m) then nMatches = nMatches + 1 if nMatches \> 1 then return false, "More than one possible key for module '" .. m .. "'. Can't decide which one to erase." end mKey = key end end if mKey then registry[mKey] = nil end return true end -- Dynamic loading local tImageNfo = require("images.sprites.p"..sheetIdx) local imageRect = display.newImageRect( tImageSheet, tImageNfo:getFrameIndex(template\_id.."p"), 92, 92 ) unrequire("images.sprites.p"..sheetIdx) tImageSheet = nil return imageRect

It will be device specific.  Image sheets take up texture memory though its more efficient than individual images.  Each device has a limited amount of memory (not storage) that could run from 256mb to 2gb or more. The OS takes up most of the available memory.  You probably should not assume your app has more than 100mb of memory to use and it could be less. Take each image sheet and multiply it’s width * height * 4 to get the approx. amount of memory the sheet will use. 

Rob

Is that approximation in bytes? Because the sizes are in pixels for me.

Right, a 100 x 200 pixel image will be 20,000 * 4 (red, green, blue and alpha channel), or 80,000 bytes.

Rob

It will be device specific.  Image sheets take up texture memory though its more efficient than individual images.  Each device has a limited amount of memory (not storage) that could run from 256mb to 2gb or more. The OS takes up most of the available memory.  You probably should not assume your app has more than 100mb of memory to use and it could be less. Take each image sheet and multiply it’s width * height * 4 to get the approx. amount of memory the sheet will use. 

Rob

Is that approximation in bytes? Because the sizes are in pixels for me.

Right, a 100 x 200 pixel image will be 20,000 * 4 (red, green, blue and alpha channel), or 80,000 bytes.

Rob