LP2-2GameClassObject

=Game Class Object =

=2. Game Object Class=

2.1. The XNA game application starts out with a structured game class. It’s broken down into four major sections. Here is how the XNA Game Class constructor looks like.



2.2. The first one is the LoadContent. This method loads images for your game. You can use class established variables or create object classes to use instead. This method starts you off with the spriteBatch variable which loads all of you image content. It interfaces with the GraphicsDevice to do all of the conversions necessary for drawing.



2.3. The Update method looks for any keyboard/game controller interaction. This is where you make things react to each other either by inserting code directly, creating functions, or writing class based methods. The update method passes in the gameTime variable that is used to smooth animation out and levels CUP performance by giving a consistent timing to the game. By default the back button is enabled for the X-Box controller. It has no function on a PC implementation.



2.4. The next portion is the Draw method. This section of the program writes the images to the screen. This is where the “magic” happens because it’s the visual representation of your vision. By default the screen that XNA produces is a window with a bleu background.



2.5. The last section is the UnloadContent method. This is where you dispose of any resources that you have used to make your game function.



2.6. Here is a blank implementation of the game class running.



Project Home Next Section