Game Development Reference
In-Depth Information
objects at tool time. These macros can remove the offending code from the tool
but allow the functionality to stay at the runtime.
7.4.5 Constructor
When programming in C++, you have a number of different guarantees. One guar-
antee is that your constructor will always be called. However, when you serialize
your object from data, your constructor is still called, but it is called during the
disk-image-conversion step, not on platform. This can make it dicult to handle
runtime initialization of information. For example, if a game system needs to re-
quest resources from the graphics system, it is not possible to do that during the
constructor.
The easiest solution to this is to add a secondary initialize method. Although
it adds another pass to the deserialization, it is dicult to completely avoid this
issue. By requiring the base object type to have a deserialize method, the load can
easily iterate through all loaded objects and call that method to handle any on-load
functionality.
7.5 Conclusions
By keeping an extremely simple interface for loading and saving files, the format
of the files that are saved and loaded can be kept completely separate from game
code. This abstraction allows two drastically different ways of serializing data.
Our XML format has minimal requirements on a metadata system but is still
extremely flexible and easy to implement. Once data has been created, it can then
be converted into a much faster and more optimal format that can be used for final
game assets.
Search WWH ::




Custom Search