Sometime crashes, sometimes blank text, and sometimes works.
I'm passing (I hope) a reference to TextDisplay::update() so It can draw all the text in keyBindMenu
which is a vector of std::strings. I'm not sure if I'm handling this correctly. My understanding of this is very weak, but I think I did it correctly (passing the ref)

int main(int argc, char** argv) {
   bool displayMenu = false;
   std::vector<std::string> keyBindMenu;
      keyBindMenu.push_back("Escape toggle this menu");
      keyBindMenu.push_back("W,A,S,D map view scroll");
      keyBindMenu.push_back("Up,Down,Left,Right keys select tile");
      keyBindMenu.push_back("+,- map zoom");
      keyBindMenu.push_back("Left Mouse button to place tile");

   sf::RenderWindow *pWindow;
   sf::RenderWindow displayWindow(sf::VideoMode(DWIN_WIDTH, DWIN_HEIGHT),
           "Map Editor");
   TextDisplay mainMenu(100, 100, 600, keyBindMenu.size()*45, displayWindow.getSize());


                       case sf::Keyboard::Escape:
                     if (displayMenu) displayMenu = false;
                     else displayMenu = true;


      if (displayMenu) {
         mainMenu.update(pWindow, keyBindMenu);

     // ****** code from TextDisplay class 
void TextDisplay::update(sf::RenderWindow *window, std::vector<std::string> &menuText) {

   // display a rect area that text will display

   for (int i = 0; i <= menuText.size(); i++) {
      text.setPosition(sf::Vector2f(textBox.left + 40, (textBox.top + 7)+
              (i * (font.getLineSpacing(MENU_TEXT_SIZE)))));

   //std::cout << "updating menu" << std::endl;
3 Years
Discussion Span
Last Post by jvasher

What compiler and operating system? Have you used your compiler's debugger to single step through the program so that you can see what's happening? You have not provided enough code to enable us to make any knowledgable comments. Attach the entire file(s) to your post so that we can test it.

Edited by Ancient Dragon


the line below was the problem the <= to should have been <. fixed it when I made that change.

 for (int i = 0; i <= menuText.size(); i++) {
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.