I have this code, in my draw function:
view->setCenter(_player->getPosition());
window.setView(*view);
_map->draw(window,view->getViewport());
and in _map the draw is
void TileMap::draw(sf::RenderWindow &window, const sf::FloatRect &_camerarect)
{
unsigned int tilesdraw(0);
for ( int i = 0; i< mapW ; i++ )
for ( int j = 0; j<mapH; j++ )
if ( _camerarect.intersects(tiles[i][j]->getGlobalBounds()) )
{
window.draw(*tiles[i][j]);
tiledisegned++;
}
std::cout<<"Tiles drawed: "<<tilesdraw<<std::endl;
}
I made that for draw only the tiles that are in the window, but its not work ( at least not draw anything ), any ideas whats I wrong?
sfml2, visual studio c++ 2010.