XNA4.0学习指南第五章代码中文注释(Game1类)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Audio;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.GamerServices;
8 using Microsoft.Xna.Framework.Graphics;
9 using Microsoft.Xna.Framework.Input;
10 using Microsoft.Xna.Framework.Media;
11
12 namespace AnimatedSprites
13 {
14 /// <summary>
15 /// 游戏类
16 /// </summary>
17 public class Game1 : Microsoft.Xna.Framework.Game
18 {
19 GraphicsDeviceManager graphics;
20 SpriteBatch spriteBatch;
21        // 声明一个spriteManger游戏组件
22 SpriteManager spriteManger;
23
24 public Game1()
25 {
26 graphics = new GraphicsDeviceManager(this);
27 Content.RootDirectory = "Content";
28 }
29
30 /// <summary>
31 /// 初始化
32 /// </summary>
33 protected override void Initialize()
34 {
35 // 将spriteManger游戏组件添加到游戏的中
36 spriteManger = new SpriteManager(this);
37 this.Components.Add(spriteManger);
38 base.Initialize();
39 }
40
41 /// <summary>
42 /// 加载游戏资源
43 /// </summary>
44 protected override void LoadContent()
45 {
46 // 实例化一个SpriteBatch,用来画Textures
47 spriteBatch = new SpriteBatch(GraphicsDevice);
48 }
49
50 /// <summary>
51 /// 卸载游戏资源
52 /// </summary>
53 protected override void UnloadContent()
54 {
55 }
56
57 /// <summary>
58 /// 游戏的更新
59 /// </summary>
60 /// <param name="gameTime">Provides a snapshot of timing values.</param>
61 protected override void Update(GameTime gameTime)
62 {
63 // Allows the game to exit
64 //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
65 // this.Exit();
66
67 base.Update(gameTime);
68 }
69
70 /// <summary>
71 /// 游戏的画图方法
72 /// </summary>
73 /// <param name="gameTime">Provides a snapshot of timing values.</param>
74 protected override void Draw(GameTime gameTime)
75 {
76 GraphicsDevice.Clear(Color.White);
77
78 base.Draw(gameTime);
79 }
80 }
81 }

posted on 2011-04-12 12:37  Osiris4Net  阅读(324)  评论(0编辑  收藏  举报

导航