Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ejack

Pages: [1]
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


2
Graphics / sf::text and vectors help
« on: April 20, 2018, 03:05:34 pm »
Hi guys, new here and to SFML as well as being a novice with c++, Im trying to make sf::Text work with a vector, usually I would use an array like so:

sf::Text example[10];

but as the size must be dynamic I cant use an array and have tried using a vector like so:

// x is a number retrieved from another class
int vector_no = x + 2;

std::vector<sf::Text> myVector( vector_no );

If you know a way to make this dynamic or get the vector or something else to work please let me know, thankyou.

Pages: [1]