Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: text from string is not visible any more  (Read 1668 times)

0 Members and 1 Guest are viewing this topic.

danersound

  • Newbie
  • *
  • Posts: 12
  • sound of the silent
    • View Profile
    • Email
text from string is not visible any more
« on: December 06, 2017, 09:55:41 pm »
i modified my code from this :
int main(){

    RenderWindow window(VideoMode(800, 600), "Scheduler Simulator",Style::Titlebar);
    Font font;
    Text menu;

    if(!font.loadFromFile("Tools/PIXEARG_.TTF")){
        std::cout<<"[MainWindow:Error] font not found" << std::endl;
    }

    menu.setFont(font);
    menu.setString("hello!!");
    menu.setCharacterSize(15);
    menu.setFillColor(Color::Red);


    while (window.isOpen()){ // main Loop
        Event event;

        while (window.pollEvent(event)){

            if (event.type == Event::Closed)
                window.close();
        }
       window.clear(Color::Black);
       window.draw(menu);
       window.display();
    }

    return 0;
}
to this
   RenderWindow window(VideoMode(1000, 600), "Scheduler Simulator",Style::Titlebar);
    Font fontMenu;
    Text menu;

    fontLoader(fontMenu);

    menu.setFont(fontMenu);
    menu.setString("hello!!");
    menu.setCharacterSize(20);
    menu.setFillColor(Color::Red);


    while (window.isOpen()){ // main Loop
        Event event;

        while (window.pollEvent(event)){

            if (event.type == Event::Closed)
                window.close();
        }
       window.clear(Color::Blue);
       window.draw(menu);
       window.display();
    }

    return 0;
and the string " menu.setString("hello!!"); " is not visible any more
 and i know why! some1 can help me??

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: text from string is not visible any more
« Reply #1 on: December 06, 2017, 10:44:17 pm »
So, basically you changed this
if(!font.loadFromFile("Tools/PIXEARG_.TTF")){
        std::cout<<"[MainWindow:Error] font not found" << std::endl;
    }
 

to this?
fontLoader(fontMenu);
 

What is the definition of fontLoader? Are you passing fontMenu by value instead of by reference?

danersound

  • Newbie
  • *
  • Posts: 12
  • sound of the silent
    • View Profile
    • Email
Re: text from string is not visible any more
« Reply #2 on: December 07, 2017, 10:15:53 am »
What is the definition of fontLoader? Are you passing fontMenu by value instead of by reference?

oh my god you right i must use pointers! thx for help! all works now!