mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
948 B
948 B
Screen Management
Example
The ScreenGameComponent manages individual Screen objects. Add a new ScreenGameComponent to your Game's Components, and the screen manager will pass Initialize LoadContent UnloadContent Update and Draw to every registered screen.
public Game1()
{
// Add the screen manager to your Components.
ScreenGameComponent screenGameComponent = new ScreenGameComponent(this);
Components.Add(screenGameComponent);
}
To register your class (MyScreen) that subclasses Screen. Just pass it into the Register function.
public Game1()
{
ScreenGameComponent screenGameComponent = new ScreenGameComponent(this);
screenGameComponent.Register(new MyScreen());
Components.Add(screenGameComponent);
}