Hi, I’ve been working on a small arcade game and I am now working on the score and the lives. When I try to edit the scoreboard to any number besides 0, I get this excpetion. Can someone give me an idea what is this reason for this error.
in the Graphics::init (). Initialize TTF_Init(); like this
if (TTF_Init() == -1) {
printf("TTF Initialization Error: %s\n", TTF_GetError());
return false;
}
//return true if no errors occurred during initialization
return true;
PS: I do have the DLL’s, fonts and other files in the Debug folder.
Below is the code for how I print the score
void Scoreboard::Score(int score) {
ClearScore();
if (score == 0) {
for (int i = 0; i < 2; i++) {
mScore.push_back(new Texture("0","emulogic.ttf", 24, { 230,230,230 }));
mScore[i]->Parent(this);
mScore[i]->Pos(Vector2(-32.0f * i, 0.0f));
}
}
else {
std::string str = std::to_string(score);
int lastIndex = str.length() - 1;
for (int i = 0; i <= lastIndex; i++) {
mScore.push_back(new Texture(str.substr(i, 1), "emulogic.tff", 24, { 230,230,230 }));
mScore[i]->Parent(this);
mScore[i]->Pos(Vector2(32.0f * (lastIndex - i), 0.0f));
}
}
}