I am trying out XNA / Monogame in Visual Studio. I find the documentation somewhat lacking in explaining how the main XNA structure operates. As I understand it, Game1.Initialize() gets called before Game1.LoadContent().
But in this code example, I have found that the Content actually IS already loaded when still inside the initialize function. In this code example you will see that "---1---" gets logged in the console BEFORE "---2---". Why is this?
GAME1.CS
protected override void Initialize()
{
base.Initialize();
// SOMEHOW LOADCONTENT HAS NOW ALREADY BEEN EXECUTED?
Console.WriteLine("----2---- STILL EXECUTING INIT CODE");
}
protected override void LoadContent()
{
Console.WriteLine("----1---- GAME1 LOADS CONTENT");
AssetsManager.LoadContent(this);
SpriteBatch = new SpriteBatch(GraphicsDevice);
}
Console output:
----1---- GAME1 LOADS CONTENT
----2---- STILL EXECUTING INIT CODE
That's because you call base.Initialize()
at the beginning of the method, which then calls the LoadContent
method. calls to base class implementations (including base.Initialize()
and base.LoadContent()
) should allways be at the end of the according method.