HeadBall  1.0
A game
AssetManager.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <SFML/Graphics.hpp>
5 #include <SFML/Audio.hpp>
6 
7 namespace HeadBall {
13  class AssetManager {
14  public:
21 
27 
34  void loadTexture(std::string name, std::string fileName);
35 
42  sf::Texture &getTexture(std::string name);
43 
50  void loadFont(std::string name, std::string fileName);
51 
58  sf::Font &getFont(std::string name);
59 
66  void loadSound(std::string name, std::string fileName);
67 
74  sf::SoundBuffer &getSound(std::string name);
75 
83  bool isTexturePresent(std::string textureName);
84 
92  bool isFontPresent(std::string fontName);
93 
101  bool isSoundPresent(std::string soundName);
102 
103  private:
104  std::map<std::string, sf::Texture> _textures;
105  std::map<std::string, sf::Font> _fonts;
106  std::map<std::string, sf::SoundBuffer> _sound_clips;
107  };
108 }
Class for managing assets.
Definition: AssetManager.hpp:13
std::map< std::string, sf::Font > _fonts
map for storing Fonts
Definition: AssetManager.hpp:105
std::map< std::string, sf::Texture > _textures
map for storing Textures
Definition: AssetManager.hpp:104
bool isSoundPresent(std::string soundName)
Check whether the Sound is present in map
Definition: AssetManager.cpp:65
void loadTexture(std::string name, std::string fileName)
Load Texture from given file into map
Definition: AssetManager.cpp:7
sf::Texture & getTexture(std::string name)
Get the Texture object.
Definition: AssetManager.cpp:16
bool isTexturePresent(std::string textureName)
Check whether the Texture is present in map
Definition: AssetManager.cpp:51
void loadSound(std::string name, std::string fileName)
Load Sound from given file into map
Definition: AssetManager.cpp:38
bool isFontPresent(std::string fontName)
Check whether the Font is present in map
Definition: AssetManager.cpp:58
~AssetManager()
Destroy the Asset Manager object.
Definition: AssetManager.hpp:26
void loadFont(std::string name, std::string fileName)
Load Font from given file into map
Definition: AssetManager.cpp:23
AssetManager()
Construct a new Asset Manager object.
Definition: AssetManager.hpp:20
sf::SoundBuffer & getSound(std::string name)
Get the Sound object.
Definition: AssetManager.cpp:46
sf::Font & getFont(std::string name)
Get the Font object.
Definition: AssetManager.cpp:31
std::map< std::string, sf::SoundBuffer > _sound_clips
map for storing Sound clips/Sound effects
Definition: AssetManager.hpp:106
Custom namespace used throughout the project.
Definition: AboutState.cpp:6