I. Key classes in xNa
Graphicsdevicemanager class: Provides developers with a way to access graphics devices on PCs, Xbox 360, or Windows Phone 7. The graphicdevice attribute of graphicsdevicemanager represents the actual graph device on the machine. Graphics Device objects play an intermediary role between xNa games and graphics cards (or, more accurately, GPUs on graphics cards, everything xNa games do on the screen must be executed through this object. Simply put, an interface on the video card is called. Note: The GPU is short for graphics processing unit. The spritebatch class is used to draw core objects of Sprite. In terms of computer graphics, the genie is defined as a 2D or 3d11 image integrated into a large scenario. A 2D game is accomplished by drawing a variety of genie (player genie, enemy genie, background genie, and so on) in a scenario. Draw a game screen through the draw () method in the spritebatch object. 2. Method: initialize method: used to initialize variables and other objects related to game1 (game) objects. The graphic device object will be instantiated here, and other objects can be initialized according to the settings of the graphic device object in the initialize method. Loadcontent method: function: The loadcontent method loads all the graphics and other content required by the game, including images, models, and sound effects. This method is called after the initialize method, and is also called when you need to reload the game's graphic content (for example, the graphics device is reset because the player changes the display settings ). After the loadcontent method is called, The game1 object enters the game loop. The loadcontent () method is called only once in a game. Update method: function: simply put, is it to modify the current image based on the image, mainly used to execute some logic design of the game. For example, refresh the page, check for collisions, and update scores. Draw () method: function: equivalent to the paint () or onpaint () method in Windows programming. Diagram of the call to run the preceding method:
The above part is taken from xNa 4.0 Learning Guide
(All Rights Reserved. For details, refer to the source)