Reputation: 287
i had success to create xna winform just like WinForms Series 1: Graphics Device tutorial. well, now i like to create some class to draw a component based by class
in xna there are several "protected void" to build a game on : DrawableGameComponent, but this is an xna winform so we have to create own graphicdevice. in xna, take a look at this "protected void" code below:
public override void Draw(GameTime gameTime)
{
// TODO: Add your drawing code here
base.Draw(gameTime);
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
i want these codes above work in class with own graphicdevice so, How can i do that?
Upvotes: 1
Views: 237
Reputation: 13198
When writing a WinForms application, you won't rely on the Draw
and Update
methods to tell you when to draw and update; instead you can override the Windows OnPaintBackground
method. For updating, you can use a Timer
object.
Upvotes: 1
Reputation: 9790
You need to add your game component which is inhereted from DrawableGameComponent
to the Game.Components
collection.
Also, you don't need to make your own graphics device.
Upvotes: 1