Time for action – customizing the Initialize() method
Add the following before the call to
MyBase.Initialize()
:Me.IsMouseVisible = True
What just happened?
By default, the mouse is not visible inside the XNA game window. Setting the IsMouseVisible
property of the running instance of the Game1
class enables the mouse cursor in Windows.
Tip
Input types on other platforms
The Xbox and Windows Phone do not have mice, so what happens when the code to enable the mouse runs on these platforms? Nothing! If a platform is not equipped to support a specific type of input, the request just returns the default values when no input is being received. It is also safe to ask other platforms about their non-existent keyboards and check the state of a gamepad on a Windows PC without one attached.
The LoadContent() method
Part of the responsibility of the base Initialize()
method is to call LoadContent()
when the normal initialization has completed. The method is used to read in any graphical and audio resources your game will need. The default LoadContent()
method is also where the spriteBatch
object gets initialized. You will use the spriteBatch
instance to draw objects to the screen during execution of the Draw()
method.