1
Graphics / Re: sf::text and vectors help
« on: April 20, 2018, 04:35:57 pm »
Thanks for the reply, I don't think I explained my problem very well, usually I would do this if I had a set number of time to iterate:
sf::Text example[10];
for (int j = 0, j < 10, j ++)
{
example[j].setFont(font);
example[j].setPosition(sf::vector2f( j , j ));
example[j].setFillColour(sf::Colour::White);
example[j].setString(std::to_string(j));
}
However, as I do not know how many iterations I will have until later in my program I was looking for something like this:
//number from different class
int iterations;
sf::Text std::vector<?> example //I know this does not work but I am unsure how to represent what I mean
for (int j = 0, j < iterations, j ++)
{
example[j].setFont(font);
example[j].setPosition(sf::vector2f( j , j ));
example[j].setFillColour(sf::Colour::White);
example[j].setString(std::to_string(j))
}
edit: changed all the 'i' in the loops to 'j' as it was turning the text italic
sf::Text example[10];
for (int j = 0, j < 10, j ++)
{
example[j].setFont(font);
example[j].setPosition(sf::vector2f( j , j ));
example[j].setFillColour(sf::Colour::White);
example[j].setString(std::to_string(j));
}
However, as I do not know how many iterations I will have until later in my program I was looking for something like this:
//number from different class
int iterations;
sf::Text std::vector<?> example //I know this does not work but I am unsure how to represent what I mean
for (int j = 0, j < iterations, j ++)
{
example[j].setFont(font);
example[j].setPosition(sf::vector2f( j , j ));
example[j].setFillColour(sf::Colour::White);
example[j].setString(std::to_string(j))
}
edit: changed all the 'i' in the loops to 'j' as it was turning the text italic