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

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.

主站蜘蛛池模板: 凌源市| 固阳县| 青川县| 都江堰市| 革吉县| 赤水市| 绥宁县| 巴林右旗| 饶阳县| 沙田区| 清远市| 将乐县| 壶关县| 惠来县| 容城县| 凤庆县| 高平市| 清丰县| 夏河县| 正镶白旗| 内江市| 乐东| 高台县| 泰顺县| 保康县| 德阳市| 浪卡子县| 芒康县| 灵丘县| 金坛市| 尤溪县| 济南市| 南靖县| 武川县| 宁蒗| 阿勒泰市| 边坝县| 和平区| 晋州市| 福贡县| 江永县|