Using the TextureHolder class for all textures
Since we have our TextureHolder
class, we might as well be consistent and use it to load all our textures. Let’s make some very small alterations to the existing code that loads textures for the background sprite sheet and the player.
Changing the way the background gets its textures
In the ZombieArena.cpp
file, find the following code:
// Load the texture for our background vertex array
Texture textureBackground;
textureBackground.loadFromFile("graphics/background_sheet.png");
Delete the code highlighted previously and replace it with the following highlighted code, which uses our new TextureHolder
class:
// Load the texture for our background vertex array
Texture textureBackground = TextureHolder::GetTexture(
"graphics/background_sheet.png");
Let’s update the way the Player
class gets a texture.
Changing the way the Player class gets its texture
In the Player.cpp...