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

Time for action – customizing the Initialize() method

Add the following code snippet to the Ini tialize() method before base:Initialize():

playerScore = 0;

What just happened?

The only initialization we need to do is set the player's score to zero. Even this initialization is not strictly necessary, as zero is the default value for an int variable, but it is a good practice not to assume that this work will have been done for us.

Tip

Initialize() versus LoadContent()

In practice, much of a game's initialization actually takes place in the LoadContent() method , which we will discuss next, instead of the Initialize() method. This is because many times the items we want to initialize require content assets in order to be properly created. One common use for the Initialize() method is to set the initial display area (resolution) and switch into full screen mode.

主站蜘蛛池模板: 沂源县| 达拉特旗| 汉阴县| 墨竹工卡县| 苍溪县| 上林县| 岳阳县| 苏尼特右旗| 饶平县| 镇沅| 六枝特区| 台南市| 噶尔县| 扎鲁特旗| 上思县| 泽普县| 平和县| 页游| 共和县| 南涧| 靖安县| 山丹县| 泾源县| 黄龙县| 古丈县| 邓州市| 通河县| 乐昌市| 湘乡市| 绥滨县| 西乌珠穆沁旗| 新田县| 临洮县| 界首市| 漳平市| 汝城县| 凤凰县| 宁波市| 阳城县| 泾川县| 龙陵县|