Game Development Reference
In-Depth Information
"./sounds/sounds.group"
"./levels/levels.itx"
}
The first line of this file is defining a new CIwResGroup class instance, which is the
class used to implement a resource group, and the first thing we do inside the curly
braces of the definition is to give the resource group a name. This name will be used
later to allow us to access the resource group.
A GROUP file should only contain a single CIwResGroup definition.
The Marmalade SDK documentation states that behavior is undefined
should you specify more than one. In practice this is not a problem
since the GROUP file is the lowest level block of resources that can be
loaded at a time, so there would be no real benefit in specifying more
than one CIwResGroup anyway.
The remaining lines of the example definition specify the resources we want to
include in this group, and most often these will just be filenames for the resources in
question. As we progress through this topic we will see some extra functionality that
the group file provides us with, but for now we'll just concentrate on the main task of
loading resources.
In the example, we are specifying three files that we want to be part of this resource
group. The first is a bitmapped image saved in the PNG file format. The next
resource is a reference to another GROUP file. When this GROUP file is loaded, the
sounds.group file will be loaded into memory as well.
The final file we are including is levels.itx , which is a standard ITX file and would
be used to create instances of our own classes.
Loading groups and accessing resources
To load a GROUP file in our program, we do the following:
CIwResGroup* pResGroup;
pResGroup = IwGetResManager()->LoadGroup("groupfile.group");
This will look in the project's data directory for the specified GROUP file, and then
load it into memory. The LoadGroup method returns a pointer to the CIwResGroup
instance that was created, which we can store away somewhere so we can release
the resource group and all its resources later.
 
Search WWH ::




Custom Search