XNA's LoadGraphicsContent API, Part 2
So, after learning about XNA's LoadGraphicsContent API, an interesting question pops up as soon as you go to implement your own DrawableComponent - why is LoadGraphicsContent a protected method on components? How do I make sure it loads and unloads it's graphic objects properly?
The answer is "You don't have to". DrawableComponent is a sneaky and underhanded beast. It stealthily calls it's own LoadGraphicsContent method the first time during Initialize(), and then subscribes to the device reset events just like your Game object does. It calls LoadGraphicsContent or UnloadGraphicsContent in response to these events. This knowledge comes in handy if you try to contain components outside the Game object.

0 Comments:
Post a Comment
<< Home