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