Hello there
I have myself a class that deals with loading fonts like so
#include "FontLoader.h"
FontLoader::FontLoader()
{
}
FontLoader::~FontLoader()
{
}
void FontLoader::LoadFont(GameStates state)
{
//Load fonts
Fonts[FontNames::Main_Font].loadFromFile("Assets/Fonts/Font.otf");
}
I then have a MainMenuState which is given a reference of my FontLoader like so
#include "MainMenuState.h"
MainMenuState::MainMenuState()
{
}
MainMenuState::~MainMenuState()
{
}
void MainMenuState::Setup(ImageLoader& imageLoaderSet, FontLoader& fontLoaderSet)
{
TextObject textObject;
textObject.Setup(200, 100, "Space Destroyer", 48, fontLoaderSet.Fonts[Main_Font]);
textObject.SetRotationAnimation(-12, 12, 0.1);
TextObjects.push_back(textObject);
}
This seems to write fine, but when I hit my draw function
void State::DrawTextObjects(sf::RenderWindow& window)
{
for (int i = 0; i < TextObjects.size(); i++)
{
TextObjects.at(i).Draw(window);
}
}
I get an error in Unhandled exception at 0x6292DCE2 (sfml-graphics-d-2.dll) in SpaceDestroyer.exe: 0xC0000005: Access violation reading location 0xCCCCCCD0, at
_Nodeptr _Pnode = _Root();
Am I passing the sf::Font the incorrect way?