sorry for the late reply
this is my Resource class
#ifndef RESOURCE_H
#define RESOURCE_H
#include <SFML/Graphics.hpp>
#include <map>
#include <string>
template<typename T> class Resource
{
public:
static const T& getResource(const std::string);
private:
static std::map<std::string,T>resource_map;
Resource();
};
template<typename T> std::map<std::string,T> Resource<T>::resource_map;
template<typename T> const T& Resource<T>::getResource(const std::string filename)
{
auto& rResource = resource_map;
auto iter = rResource.find(filename);
if ( iter != rResource.end() )
return iter->second;
else
{
auto& _key_pair = rResource[filename];
_key_pair.loadFromFile(filename);
return _key_pair;
}
}
#endif // RESOURCE_H
in any case if this is working:
void MainScreen::showMainScreen()
{
WindowManager::getGameWindow().draw(sf::Text("NEWGAME",sf::Font(Resource<sf::Font>::getResource("resources//fonts//arial.ttf")),50));
}
this must be working too
sf::Text MainScreen::NEWGAME("NEWGAME",sf::Font(Resource<sf::Font>::getResource("resources//fonts//arial.ttf")),50);
void MainScreen::showMainScreen()
{
WindowManager::getGameWindow().draw(NEWGAME);
}