Game Development Reference
In-Depth Information
method used in games is to convert all data to a serialized format that can be eas-
ily read by the resource system. This allows for extra speed when loading because
you don't need to parse generic content files, and makes it easier to secure your
data and load it in. The Microsoft XNA Framework has a great example of this in
the content pipeline, where ContentProcessors and ContentImporters work
at the build stage to create the serialized file from source data. These files then rep-
resent serialized versions of the final objects used in the game, and using a little bit
of reflection or an easily written ContentReader , a file can be loaded at runtime
quickly and easily. This entire system allows the developer to load a file by specifying
the resulting type and the path to the serialized file, with all of the loading happening
behind the scenes.
Note
Reflection allows you to inspect classes, interfaces, fields, and methods at
runtime. This allows you to write code that can dynamically create and interact
with classes that you do not know about at compile time.
The XNA Content Pipeline
The point of this system is to have a way to re-use loaded data. This is done through
the implementation of a cache , which can be simple or complex, depending on the
needs of the game. If you consider the amount of memory and video RAM available
to gamers today you'll see that smaller games can quite easily cache everything in
memory and have no issues. If you're writing a larger game with a lot of graphics
and audio assets, or you're writing for a limited platform such as a phone, you may
Search WWH ::




Custom Search