What differences are there between Initialize and LoadContent? I have tried to brake the XNA game by moving things from LoadContent to Initialize and back but as long as you call things the appropriate way everything works no matter where I put it.
The documentation for LoadContent
states that
This method is called by Initialize
The documentation for Initialize
states
In classes that derive from Game, you need to call base.Initialize in Initialize, which will automatically enumerate through any game components that have been added to Game.Components and call their Initialize methods.
So the base initialize method will initialize game components before any content is loaded, the LoadContent method ensures that your resources are loaded at the appropriate time.
Game.Run()
(see your Program.cs, i.e. game.Run()
) is the method that runs:
1) Game.Initialize()
(Which calls Game1.Initialize()
and the initial Game1.LoadContent()
).
2) Game.BeginRun()
(which calls Update()
, Draw()
and subsequent LoadContent()
/UnloadContent()
(generally speaking).
MSDN - Game Class
In other words, initial LoadContent()
statements can be put into Initialize()
, but the problem is when you want to load, reload or unload things after initialization is done.
In short: Keep all your loaded content in LoadContent()
, to avoid confusion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With