Question about STI, sorry if already answered, I didn't found anything...
I'm trying to write a lazy-loader for different maps into a platformer game. Maps are made with Tiled and loaded into Love2D with STI (btw, thanks for this module @Karai17!), at this point I realized that everytime I switch to another map, the old map seems still loaded. Example, I've got the following code to get the graphic stats, because I noticed an increment of memory everytime I get into a new level/map:
Code: Select all
local stats = love.graphics.getStats()
print("Canvases: " .. stats["canvases"]
print("Texture Memory: " .. stats["texturememory"] / 1024 / 1024
Each map has 2 layers, tiles and objects. For the first map, the Canvases value is 2, OK. Second map, 4. Third map, 6... And the texture memory, increases by 12-13 MB each time.
My lazy loader has the following code:
Code: Select all
local levelList = {
'level01',
'level02',
'level03'
}
function Level:load(level)
map = sti("assets/maps/" .. levelList[level] .. ".lua", { "box2d" })
return map
end
Actually is just an "array of levels" and loader by selector. There is no function to unload the level. Everytime I call Level:load(), also sets the variable to nil and load it again. But I think there should be any way to unload/release the old unneeded canvases, isn't it? Maybe I just forgot something...