Putting this together should be something you can achieve now. So, take the source code of the main.lua
file we created previously and modify it in order to make use of our ResourceManager
and ResourceDefinitions
entities. You’ll need to include resource_definition.lua
and resource_manager.lua
in main.lua
and then make good use of them. If you download the source code for this chapter from the website, main.lua
has already been modified to work with ResourceManager
.
Another exercise is to code a way to unload assets from ResourceManager
. This has also been done in the code for this chapter, which you can download from the website.
Note
The unload
method is pretty important since it will be needed in order to actually free the memory reserved for assets.
Another interesting topic to enhance our ResourceManager
entity is the use of serialized fonts so font loading is faster at runtime.