1
Graphics / Re: Cannot create a version of font that isn't destroyed for Text
« on: July 09, 2022, 10:09:12 pm »
For anyone looking I had to create the object t as a reference to an index of display array prior to assigning any characteristics to the obj.
Here is the updated code:
Here is the updated code:
void SetStats::populateDisplayVec()
{
int posX = 100;
int posY = 100;
int track = 0;
//for (auto& text : setsArray)
int temp = 3 * 11 + 50;
displayArray.resize(temp);
for (int i = 0; i < setsArray.size(); i++)
{
for (int j = 0; j < 11; j++)
{
sf::Text &t = displayArray[track];
track++;
// Set text params
t.setFont(font);
t.setCharacterSize(24);
t.setFillColor(sf::Color::Black);
int num = setsArray[i][j];
std::string st = (std::to_string(num));
std::string s = " " + st + ", ";
t.setString(s);
// Bump to next set
if (j == 0)
{
posY += 60;
posX = 100;
}
std::cout << std::to_string(posX) << ", " << std::to_string(posY) << " ";
t.setPosition(sf::Vector2f(posX, posY));
posX += 60;
// Removed -> displayArray.push_back(t);
};
}
}
{
int posX = 100;
int posY = 100;
int track = 0;
//for (auto& text : setsArray)
int temp = 3 * 11 + 50;
displayArray.resize(temp);
for (int i = 0; i < setsArray.size(); i++)
{
for (int j = 0; j < 11; j++)
{
sf::Text &t = displayArray[track];
track++;
// Set text params
t.setFont(font);
t.setCharacterSize(24);
t.setFillColor(sf::Color::Black);
int num = setsArray[i][j];
std::string st = (std::to_string(num));
std::string s = " " + st + ", ";
t.setString(s);
// Bump to next set
if (j == 0)
{
posY += 60;
posX = 100;
}
std::cout << std::to_string(posX) << ", " << std::to_string(posY) << " ";
t.setPosition(sf::Vector2f(posX, posY));
posX += 60;
// Removed -> displayArray.push_back(t);
};
}
}