So. i seem to have a small problem here.
I got a number of Buttons (a class i made) stored in a vector like so:
vector<Buttons> _Btns;
now, all _Btns members have been initialized. each contain a
sf rect
sf text
void render(sf::RenderWindow& l_window)
int update(int x, int y)
and some other functions and variables that are irrelevant to this problem.
now, i update the buttons like so:
int updated = 0; for (auto itr = _Btns.begin(); itr != _Btns.end(); ++itr) { itr->update(sf::Mouse::getPosition(l_window).x / 2, sf::Mouse::getPosition(l_window).y / 2); if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) { updated = itr->TestPress(); if (updated != 0) current = updated; } } |
No problem there.
now, rendering gets a bit odd.
This works:
_Btns.back().render(l_window); |
except that it only lets me render the last button added.
but this:
for (auto itr = _Btns.begin(); itr != _Btns.end(); ++itr) { itr->render(l_window); } |
does not?
neither does:
_Btns.front().render(l_window); |
Now, seeing as i can iterate with the update function, and I can render calling only the "back()"
I'm at a lost... what should i do to iterate and render my _Btns?
//I will get back with the answer if i find it first, but after 12 hours of google search I'm a bit done for!
//i know, the update function is not need in this example, it was just to show that one form works, another does not :S