December 2015
Beginner to intermediate
522 pages
11h 21m
English
Before we start to build the structure of our graphical user interface, we need a way to manage and handle the loading and unloading of fonts automatically, just like we did with textures. The effort we put into the resource manager written back in Chapter 6, Set It in Motion! – Animating and Moving around Your World, is about to pay off. In order to manage fonts, all we need to do is create a FontManager.h file and write the following code:
class FontManager : public ResourceManager<FontManager, sf::Font>{ public: FontManager() : ResourceManager("fonts.cfg"){} sf::Font* Load(const std::string& l_path){ sf::Font* font = new sf::Font(); if (!font->loadFromFile( Utils::GetWorkingDirectory() + l_path)) { delete font; font = nullptr; ...Read now
Unlock full access