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

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.

主站蜘蛛池模板: 桃园县| 涿鹿县| 高雄市| 和静县| 安庆市| 沂源县| 甘南县| 彭山县| 卢龙县| 蕲春县| 八宿县| 德清县| 镇安县| 晋城| 鄢陵县| 抚宁县| 太仆寺旗| 济阳县| 田东县| 武川县| 故城县| 桦甸市| 昆山市| 连州市| 浦县| 水城县| 攀枝花市| 广元市| 冷水江市| 鱼台县| 盐城市| 北京市| 兴和县| 家居| 奉节县| 麻栗坡县| 卢氏县| 禄劝| 团风县| 静宁县| 漳平市|