Game Development Reference
In-Depth Information
Earlier we had to create our own instance of CIwTextParserITX
in order to parse an ITX file. IwResManager creates its own instance
of CIwTextParserITX when it needs it, so we don't need to
worry about creating our own instance.
Adding IwResManager to a project
To make the IwResManager API available to a project, all that needs to be done is to
add iwresmanager to the subprojects list in the MKB file.
To initialize the API just add a call to IwResManagerInit , which will create a
singleton instance of the Marmalade resource manager class CIwResManager . This
class is used to load, free, and of course access our projects resources, whatever they
may be. The singleton can be accessed using the function IwGetResManager .
When our project terminates we should call IwResManagerTerminate , which will
destroy the resource manager singleton and any resources it may still have loaded
in memory.
Specifying resources with a GROUP file
Marmalade allows us to collect different types of resources together into a resource
group. We are free to mix images, sounds, 3D models, and any other data types we
might need to use.
Why would we want to group resources together? Well, let's say you are writing a
game with a number of different levels. Each level will have some common resources
(for example, the player graphics) but might have unique elements specific to that
level, so it would make sense to only have these resources in memory when the
level is being played. You could therefore create one resource group for the player
graphics, and individual ones for each level.
In order to load a resource group into our program, we first need to create a GROUP
file. A GROUP file is actually an ITX file with the extension .group that allows us to
list all the resources we want to gather together.
Let's start by taking a look at a sample GROUP file:
CIwResGroup
{
name "game_resources"
"./images/titlescreen.png"
 
Search WWH ::




Custom Search