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

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.

主站蜘蛛池模板: 白沙| 梁山县| 石狮市| 重庆市| 射洪县| 福安市| 博罗县| 沂源县| 清徐县| 越西县| 柏乡县| 钟山县| 汾西县| 靖边县| 新建县| 红河县| 武安市| 邵阳县| 鄂托克前旗| 同心县| 景德镇市| 恩平市| 绵竹市| 乌苏市| 涿州市| 长阳| 翁牛特旗| 同心县| 江津市| 丰都县| 博白县| 泸溪县| 铅山县| 罗源县| 江山市| 彩票| 上饶县| 永寿县| 巫溪县| 朝阳区| 巴里|