Game Development Reference
In-Depth Information
We'll take one more look at WidgetClass to wrap this all up. You may
remember that it had a member mpNextWidget that points to another instance of
WidgetClass . In the ITX file, we supplied a value for this member by specifying
the name of another WidgetClass instance. In the ParseAttribute method, we
read in this name and calculated a hash value from it which was stored in the
mNextWidgetHash member variable.
We can implement the Resolve method and look up a pointer to the correct instance
but we'll also need to maintain a list of all WidgetClass instances in order to do this.
One way of doing this is to implement ParseClose and store each instance in a list.
The following code shows how this could be achieved:
void WidgetClass::ParseClose(CIwTextParserITX* apParser)
{
// Add this instance to a list. gpWidgetList is an instance of a
// Marmalade class called CIwManagedList which is very useful
// for storing lists of objects derived from CIwManaged!
gpWidgetList->Add(this);
}
void WidgetClass::Resolve()
{
// Look up an instance of WidgetClass with the given hash
if (mNextWidgetHash)
{
mpNextWidget = static_cast<WidgetClass*>
(gpWidgetList->GetObjHashed(mNextWidgetHash));
}
}
The Marmalade resource manager
Most bitmap art packages are capable of saving images in a number of different file
formats, but we really need access to the actual bitmap data itself, which may well be
stored in a compressed format with any particular file format.
Marmalade makes the task of loading images simple by way of the IwResManager
API. This API relies upon the ITX file format we have just discussed, and is not just
limited to loading images. It can also be used to load in data such as 3D models and
animations, and we can also use it to keep track of our own custom classes.
 
Search WWH ::




Custom Search