example:
Code: Select all
local asrl = require("asrl")
local cache = asrl.newCache()
cache:addLoader("registerImage", love.graphics.newImage)
-- sometimes first entry is not a unique key so we need a key function
local function font_keyfunc(name, pt)
if type(name) == "string" then return ("%s_%s"):format(name, pt) end
if type(name) == "number" then return ("%s_%s"):format("default_font", name) end
end
cache:addLoader("registerFont", love.graphics.newFont, font_keyfunc)
cache:addLoader("registerAudio", love.audio.newSource)
...
cache:invalidate()
...
local font = cache:registerFont("assets/somefont.ttf", 16)
...
cache:cleanup()