Tuesday, August 7, 2012

C# : XNA 4.0: displaying an image to the screen


this code will enable you to display an image using C# XNA 4.0.

Game1.cs


Most of this code is generated by microsoft visual studio when you create your XNA game project in the Game1.cs file. The following includes some code not included in the template that create the final result.
This line of code creates a Texture2D object named "manifestCodeLogo1"

These lines of code change the screen resolution of the application. In this case I have chosen to have a 512x512 resolution application.

this line of code loads the image from this projects Content Library:


this code is responsible for drawing manifestCodeLogo1 and positioning it in the center of the application window:

No comments:

Post a Comment