generated from polaritynord/polarity-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassets.lua
More file actions
49 lines (45 loc) · 1.32 KB
/
assets.lua
File metadata and controls
49 lines (45 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local assets = {
images = {};
sounds = {};
fonts = {};
defaultImages = {};
defaultSounds = {};
mapImages = {};
mapSounds = {};
}
function assets:unloadSceneAssets()
--remove images
for k, v in pairs(assets.images) do
assets.images[k]:release()
assets.images[k] = nil
end
assets.images = {}
--remove sounds
for k, v in pairs(assets.sounds) do
assets.sounds[k]:stop()
assets.sounds[k]:release()
assets.sounds[k] = nil
end
assets.sounds = {}
end
function assets:unloadMapAssets()
--remove images
for k, v in pairs(assets.mapImages) do
assets.mapImages[k]:release()
assets.mapImages[k] = nil
end
assets.mapImages = {}
--remove sounds
for k, v in pairs(assets.mapSounds) do
assets.mapSounds[k]:stop()
assets.mapSounds[k]:release()
assets.mapSounds[k] = nil
end
assets.mapSounds = {}
end
function assets.load()
assets.defaultSounds.button_click = love.audio.newSource(GAME_DIRECTORY .. "/assets/sounds/button_click.wav", "static")
assets.defaultSounds.button_hover = love.audio.newSource(GAME_DIRECTORY .. "/assets/sounds/button_hover.wav", "static")
assets.defaultImages.missing_texture = love.graphics.newImage("engine/assets/missing_texture.png")
end
return assets