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

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.

主站蜘蛛池模板: 太湖县| 琼海市| 洪雅县| 崇仁县| 瑞昌市| 饶阳县| 东乌| 嘉义市| 三亚市| 宽城| 鹤岗市| 吴旗县| 宁陵县| 精河县| 页游| 新野县| 达孜县| 蓬安县| 唐海县| 永修县| 尉氏县| 县级市| 牙克石市| 汉川市| 东乡县| 西乡县| 威远县| 怀化市| 沙坪坝区| 景泰县| 洛扎县| 贵州省| 琼海市| 科技| 龙江县| 石柱| 潼关县| 景泰县| 万宁市| 武宁县| 新河县|