|
![](/i/fill.gif) |
> In MS's simple game libraries, there's a class called GameComponent.
> It inherits from IUpdatable, IDrawable, and IMumble, each of which
> provides the declaration of one of the main routines in a game (update,
> draw, and initialize, respectively).
>
> Now, if I wanted (and I do) to make a collection of things that act like
> GameComponent objects but aren't necessarily game components, I don't
> think I can do that in C#. I would have to have a collection parameterized
> on all three of those interfaces.
If you cannot (or don't want to) derive your custom class(es) from
GameComponent then the common base class will be System.Object. You then
have to make a collection of these if you want to store both GameComponent
and your custom class, eg:
List<Object> myList;
...
foreach( Object o in myList )
if( o is IUpdatable )
(o as IUpdatable).Update();
> In any case, it's rather annoying. :-) I might have to figure out how to
> patch up MS's samples to also host a collection of game components as well
> as the scene-activation/deactivation they do.
Yeh, I think the XNA management classes are only meant to be simple ones to
get you started, most things I've read advocate replacing the whole
GameComponent system with your own (usually based on "screens" and adding
components to each "screen").
Post a reply to this message
|
![](/i/fill.gif) |