Difference between revisions of "XNA Game Components"

esse quam videri
Jump to: navigation, search
m (Text replacement - "<csharp>" to "<syntaxhighlight lang="csharp" line="1" >")
m (Text replacement - "</csharp>" to "</syntaxhighlight>")
Line 44: Line 44:
 
     }
 
     }
 
}
 
}
</csharp>
+
</syntaxhighlight>

Revision as of 18:28, 25 January 2016


Most Game components will inherit the structure of the Game Class.

Here is a class classed Sprite that was created as an XNA Game Component. I have not added and methods to this class yet. Notice that when you create a game component it already has some of the Template:XNA structure

 1 namespace WindowsGameDemo
 2 {
 3     /// <summary>
 4     /// This is a game component that implements IUpdateable.
 5     /// </summary>
 6     public class Sprite : Microsoft.Xna.Framework.GameComponent
 7     {
 8         public Sprite(Game game)
 9             : base(game)
10         {
11             // TODO: Construct any child components here
12         }
13 
14 
15         /// <summary>
16         /// Allows the game component to perform any initialization it needs to before starting
17         /// to run.  This is where it can query for any required services and load content.
18         /// </summary>
19         public override void Initialize()
20         {
21             // TODO: Add your initialization code here
22 
23             base.Initialize();
24         }
25 
26 
27         /// <summary>
28         /// Allows the game component to update itself.
29         /// </summary>
30         /// <param name="gameTime">Provides a snapshot of timing values.</param>
31         public override void Update(GameTime gameTime)
32         {
33             // TODO: Add your update code here
34 
35             base.Update(gameTime);
36         }
37     }
38 }