In order to be able to define resources, we need to create a module that will be in charge of handling this. The main idea is that before calling a certain asset through ResourceManager
, it has to be defined in ResourceDefinitions
. In this way, ResourceManager
will always have access to some metadata it needs to create the asset (filenames, sizes, volumes, and so on).
In order to identify the asset types (sounds, images, tiles, and fonts), we will define some constants (note that the number values of these constants are arbitrary; you could use whatever you want here). Let’s call them RESOURCE_TYPE_[type]
(feel free to use another convention if you want to). To make things easier, just follow this convention for now since it’s the one we’ll use in the rest of the book. You should enter them in main.lua
as follows:
RESOURCE_TYPE_IMAGE = 0 RESOURCE_TYPE_TILED_IMAGE = 1 RESOURCE_TYPE_FONT = 2 RESOURCE_TYPE_SOUND = 3
If you want to understand the actual reason behind these...