Difference between revisions of "XNA Game Components"

esse quam videri
Jump to: navigation, search
m (Text replacement - "<csharp>" to "<syntaxhighlight lang="csharp" line="1" >")
Line 5: Line 5:
 
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]]
 
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]]
 
   
 
   
<csharp>
+
<syntaxhighlight lang="csharp" line="1" >
 
namespace WindowsGameDemo
 
namespace WindowsGameDemo
 
{
 
{

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

<syntaxhighlight lang="csharp" line="1" > namespace WindowsGameDemo {

   /// <summary>
   /// This is a game component that implements IUpdateable.
   /// </summary>
   public class Sprite : Microsoft.Xna.Framework.GameComponent
   {
       public Sprite(Game game)
           : base(game)
       {
           // TODO: Construct any child components here
       }


       /// <summary>
       /// Allows the game component to perform any initialization it needs to before starting
       /// to run.  This is where it can query for any required services and load content.
       /// </summary>
       public override void Initialize()
       {
           // TODO: Add your initialization code here
           base.Initialize();
       }


       /// <summary>
       /// Allows the game component to update itself.
       /// </summary>
       /// <param name="gameTime">Provides a snapshot of timing values.</param>
       public override void Update(GameTime gameTime)
       {
           // TODO: Add your update code here
           base.Update(gameTime);
       }
   }

} </csharp>