What's the point of having an initialization method?

Hey, I’m a beginner who’s just starting to learn c# and MonoGame, and so, I was wondering why MonoGame has an initialize method when there’s already the constructor? they’re both called only once, right? what’s the point of having an initialization method?

I’m probably not fully qualified to answer this but I can point out that I noticed complications can arise if certain initializations happen in the constructor (ie: it won’t work) instead of initialize (or load). I’m not sure what the reason is - possibly certain things need to be ready(?)

GraphicsDevice is null and uninitialized during the constructor but has a value by the time of the initialize method, so some behind-the-scenes set-up definitely occurs between the constructor and the initialize method.

1 Like

This doesn’t really explain the “why”, but on a related note this doc does at least explain the “what” of these various lifecycle methods.

https://docs.monogame.net/articles/getting_started/3_understanding_the_code.html

The constructor prepares the class for use so that you can call its methods and access its properties. Initialize() is called by Monogame where you initialize your game objects. Think of Initialize() being called as if your game is restarting from any random state. Of course you can really do whatever you want.

Also I’ve noticed that base.Initialize() calls LoadContent() so I would order it so that base.Initialize() is the first line inside the Initialize method.