1
Window / Re: SFML 2.0 and sf::view
« on: June 14, 2012, 04:12:58 pm »
Here is the function I call at the line you mentionned.
It's very simple, I iterate on a std::list of objects, and I draw them in the window.
I don't understand what do you mean by window.setView(_app->setView(_view));. I don't have any kind of window variable. My variable _app is the variable which initialize the screen.
Thank you for your help.
Edit:
I solved my problem.
Indeed, the _app->setView method was called at the wrong place.
void Map::drawSprites()
{
std::list<Object>::iterator it;
int pos_x;
int pos_y;
for (it = _listObject.begin(); it != _listObject.end(); ++it)
{
sf::Vector2<unsigned int> vectorWinSize;
sf::Vector2<unsigned int> vectorImageSize;
vectorWinSize = _app->getSize();
vectorImageSize = _imageMap["grass"].getSize();
pos_x = ((*it).getX() - (*it).getY()) * (vectorImageSize.x / 2) + (vectorWinSize.x / 2);
pos_y = ((*it).getX() + (*it).getY()) * (vectorImageSize.y / 2 - 4) + 50;
sf::Sprite sprite;
sprite.setTexture(_imageMap["grass"]);
sprite.move(pos_x, pos_y);
_app->draw(sprite);
}
}
{
std::list<Object>::iterator it;
int pos_x;
int pos_y;
for (it = _listObject.begin(); it != _listObject.end(); ++it)
{
sf::Vector2<unsigned int> vectorWinSize;
sf::Vector2<unsigned int> vectorImageSize;
vectorWinSize = _app->getSize();
vectorImageSize = _imageMap["grass"].getSize();
pos_x = ((*it).getX() - (*it).getY()) * (vectorImageSize.x / 2) + (vectorWinSize.x / 2);
pos_y = ((*it).getX() + (*it).getY()) * (vectorImageSize.y / 2 - 4) + 50;
sf::Sprite sprite;
sprite.setTexture(_imageMap["grass"]);
sprite.move(pos_x, pos_y);
_app->draw(sprite);
}
}
It's very simple, I iterate on a std::list of objects, and I draw them in the window.
I don't understand what do you mean by window.setView(_app->setView(_view));. I don't have any kind of window variable. My variable _app is the variable which initialize the screen.
Thank you for your help.
Edit:
I solved my problem.
Indeed, the _app->setView method was called at the wrong place.