I found a few topics with this error but none really looked similarly to my issue so here I go.
I have a class that has a vector of sf::Text. Then it has functions to set everything up like fonts sizes and coordinates so thats fine. Next I'd like to draw the text from main, as it's private in a class I tried to do it from the classes function like that:
void Player::drawCards(sf::RenderWindow &window)
{
for(int i = 0; i<3; i++)
{
window.draw(myclues[i]);
}
}
That didn't work out, so I made a function that returns the text.
sf::Text Player::retClu(int i)
{
return myclues[i];
}
And then use it in main.cpp like so (the class - player, is also in a vector so I can do this for each generated class) :
for (int i = 0; i < numb_of_players; i++)
{
for (int j = 0; j < 3; j++)
{
window.draw(vPlayers[i].retClu(j));
}
}
And yet again I get the error:
Exception thrown at 0x508D485F (sfml-graphics-d-2.dll) in forensic_15.exe: 0xC0000005: Access violation reading location 0x00000004.
I've tried many different ways of coding this but I must have some misunderstanding of how it can/should be done because I get this error every time.
Thanks for any replies.