Rendering Sprites
Direct3D already has an object that can be thought of as a sprite, namely the texture. However, textures must be rendered onto some type of primitives in order to be seen by the user. The Sprite class handles this work for you. Add the following variables for your application:
private Texture spriteTexture; private Sprite sprite; private Rectangle textureSize;
These obviously store the texture that will be used to render the sprite, as well as the sprite itself. You will also need to know the size of the texture in order to render it correctly, so that will be stored as well. At the end of your initialization method, directly after the device has been created, you will need to initialize these variables as follows:
// Create ...
Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.