• Advertisement
Sign in to follow this  

GameComponent vs DrawableGameComponent... thoughts?

This topic is 1650 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

XNA has two seperate component objects I've run into.  I've been for my 2D games just using GameComponent and that was mainly to represent different screens.  (title screen, main screen, end screen, etc)

 

I note that we also have a DrawableGameComponent.  

My question is ... what's the difference in the two?

Share this post


Link to post
Share on other sites
Advertisement

Tip, in visual studio when you see a class that looks unfamiliar, type it out into the code editor then right click and choose "Go To Definition" or click on the text and press F12. This will take you to a window that shows how the class is seen by reflection.

 

dgc.jpg

 

In this case you can see the DrawableGameComponent class inherits the GameComponent class, and the IDrawable interface. So basically it's a derivative of the GameComponent class that implements methods found in IDrawable including the Draw method. This however doesn't meant it's the only one you can use, in fact you could write your own version of DrawableGameComponent that includes your own set of methods, the XNA team created this class as a prefabricated example of how to make a customized GameComponent smile.png

 

Aimee

Edited by AmzBee

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement