O'Reilly logo

Learning Windows 8 Game Development by Michael Quandt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drawing the sprites

Now we need to get those images onto the screen. Using DirectXTK we have access to a class called SpriteBatch. If you have used XNA before, you might recognize this class and remember that it is an excellent way to render 2D images with all of the effort and optimization done for you.

For this we need to prepare the SpriteBatch inside our Game class so we can render the textures we have created, and then from there add some code to the Texture class so that we can finally draw these images.

Let's begin by defining a shared pointer to a SpriteBatch object within the Game class. Remember that DirectXTK defines all of its classes within the DirectX namespace, so you'll need to create something like the following:

std::shared_ptr<DirectX::SpriteBatch> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required