title: SFML/C++ Sprite is being displayed as a white box due to going out of scope, don't know where
body: <p>Title describes everything, I'm trying to do a tile-based engine, but i can't continue because I just can't find where the texture goes out of scope.</p>
  
  <p>Thank you.</p>
  
  <p>My code:</p>
  
  <p>ImageManager.h</p>
  
  <pre><code>#pragma once
  
  #include &lt;SFML/Graphics.hpp&gt;
  #include &lt;vector&gt;
  
  class ImageManager{
      std::vector&lt;sf::Texture&gt; textureList;
  public:
  
      void AddTexture(sf::Texture);
      sf::Texture getIndex(int index) const;
  };
  </code></pre>
  
  <p>ImageManager.cpp</p>
  
  <pre><code>#include "imageManager.h"
  
  void ImageManager::AddTexture(sf::Texture texture){
      textureList.push_back(texture);
  }
  
  sf::Texture ImageManager::getIndex(int index) const{
      return textureList[index];
  }
  </code></pre>
  
  <p>Tile.h</p>
  
  <pre><code>#pragma once
  
  #include &lt;SFML/Graphics.hpp&gt;
  #include &lt;memory&gt;
  
  class Tile{
      sf::Sprite sprite;
  
  public:
      Tile(sf::Texture texture);
  
      void draw(int x, int y, sf::RenderWindow* rw);
  };
  </code></pre>
  
  <p>Tile.cpp</p>
  
  <pre><code>#include "Tile.h"
  
  Tile::Tile(sf::Texture texture){
      sprite.setTexture(texture);
  }
  
  void Tile::draw(int x, int y, sf::RenderWindow* rw){
      sprite.setPosition(x, y);
      rw-&gt;draw(sprite);
  }
  </code></pre>