dynamic sprite loading
This commit is contained in:
parent
c575497b3f
commit
738398fc2b
2 changed files with 21 additions and 3 deletions
|
@ -1,11 +1,13 @@
|
|||
require 'lib.audio'
|
||||
|
||||
local assets = {}
|
||||
local rawsprites = {}
|
||||
|
||||
function assets.clear()
|
||||
print("ℹ️ clearing assets")
|
||||
|
||||
sprites = {}
|
||||
rawsprites = {}
|
||||
sound_path = {}
|
||||
music_path = {}
|
||||
end
|
||||
|
@ -13,8 +15,15 @@ end
|
|||
function assets.load(base)
|
||||
print("ℹ️ loading " .. base)
|
||||
|
||||
assets.addSprites(base)
|
||||
print("✓ added sprites")
|
||||
setmetatable(sprites, {__index = function(tbl, i)
|
||||
if rawsprites[i] then return rawsprites[i] end
|
||||
local sprite = love.graphics.newImage('assets/sprites/' .. i .. '.png')
|
||||
rawsprites[i] = sprite
|
||||
return sprite
|
||||
end})
|
||||
|
||||
--assets.addSprites(base)
|
||||
--print("✓ added sprites")
|
||||
|
||||
assets.addAudio(base)
|
||||
print("✓ added audio")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue