XNA WP7 Mango: DrawableGameComponent can be dynamically added to Microsoft.Xna.Framework.Game?

It seems that the class inherited from DrawableGameComponent can be added to Xna.Framework.Game only at Initialize() phase in Game1. Later than that, the component's Draw won't be called. Is there any workaround? The components can be dynamically created at run-time. I need to add the component to be drawn. Thanks!

Answers


Components can be addded to the Game.Components collection whereever you want. If you add a component in the e.g. Update() method, even its Initialize() and LoadContent() methods are called. To draw all components, make sure that the Game.Draw() method contains a call to base.Draw().

If you are experiencing problems only because components are added later, then the problem is probably in the component itself or somewhere else. Make sure that everything exists that the component relies on.


Need Your Help

Having split HTML divs by heading type, how to extract the one I'm interested in?

python html xml xpath lxml

Given a page such as this, with two jobs (we'll ignore 'Open applications' for now) fully described one after the other, I can detect if there is a job matching a keyword by applying the following ...

How to export Latex table to PDF in R?

r pdf latex

I produced a table in R and used Hmisc:latex to convert it to latex, but now I am not sure how to render the Latex result to a PDF table.