ScreenManager is a static class responsible for managing the flow of the game between Screen.
The CurrentScreen property references the ScreenManager's current Screen. Only one Screen can be active at one time.
This property is set automatically by the ScreenManager when a new Screen is created. This can occur through:
The FlatRedBall.Screens.ScreenManager.Start method
The FlatRedBall.Screens.Screen.MoveToScreen method
The FlatRedBall.Screens.Screen.IsActivityFinished property
The CurrentScreen property cannot be set directly. For more information on when the CurrentScreen is initially see the FlatRedBall.Screens.ScreenManager.Start method.
Initially CurrentScreen is usually set in generated code by the FlatRedBall Editor according to the startup screen. After initial setting, any of the calls mentioned above can be used to change the CurrentScreen.
CurrentScreen is set internally by the ScreenManager after the Screen has been instantiated but before CustomInitialize has been called. Therefore, the CurrentScreen will always equal "this" in the CustomInitialize call.
The CurrentScreen will remain the same throughout a Screen's life, persisting through the CustomActivity and CustomDestroy calls.
Since the Screen has not yet been initialized, the CurrentScreen will not be set when a Screen's CustomLoadStaticContent method is called.
The Activity function in the ScreenManager is responsible for:
Calling Activity on the current Screen
Performing async screen loading activity
Transitioning between Screens if the current Screen's IsActivityFinished is true.
The Start method is a method which sets the first Screen in the execution of your game. After Start is called, a typical FlatRedBall game will always have one screen active. In other words, the CurrentScreen property will always be non-null.
The Start method is typically called in Game1.cs. If using Glue, the Start call is automatically added for you in a project, and it is automatically updated whenever the "StartUp Screen" is changed. The Start call usually does not need to be written or modified if using Glue.
A typical Start call looks like: