With the proposed code from Visual Studio, which automatically initializes the object SpriteBatch, class of XNA that is committed to draw the sprites on the screen, we can directly use this instance to draw the image. The method Draw class SpriteBatch must always be between a call to Begin and a call to the End : This technique allows you to group several operations into one transaction to design video. The code to draw our image on the screen, as Texture2D loaded in the Load method is as follows:
Code:
spriteBatch.Begin ();
spriteBatch.Draw (logoTexture, new Vector2 (0, 0), Color.White);
spriteBatch.End ();
Running our application with the classic F5 , you will get the emulator that will present our image in the upper left, as we indicated in the preceding code using the class Vector2 , a two-dimensional vector, which contains the values for 'X and Y axis (by default, the location of image is calculated by taking as a reference point in the upper left corner of the image).
Bookmarks