官术网_书友最值得收藏!

Time for action – customizing the Initialize() method

  1. 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.

主站蜘蛛池模板: 溧阳市| 临桂县| 蒙山县| 梁河县| 宝兴县| 高密市| 新营市| 彭泽县| 太原市| 宁津县| 台湾省| 东港市| 柞水县| 秀山| 乌鲁木齐县| 南雄市| 屏东县| 阜平县| 松桃| 建始县| 古丈县| 陇川县| 麻栗坡县| 会泽县| 南澳县| 交口县| 泸水县| 四子王旗| 呼图壁县| 平遥县| 西和县| 江山市| 崇州市| 苗栗市| 沂水县| 綦江县| 镇远县| 类乌齐县| 天等县| 清丰县| 崇文区|