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

Author Topic: Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

SSLukeY

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.
I don't get why my code is wrong, and I don't know what this means, any help?

int main()
{
       
        RenderWindow window(VideoMode(800,600), "SFML Game");  
        window.setFramerateLimit(60);        

        bool play = true;
        Event event;

        bool titleDisplay = true;

        Font font;
        if (font.loadFromFile("Data/arial.ttf") == 0) {
                return 1;
        }

        Text titleText;
        titleText.setFont(font);
        titleText.setCharacterSize(20);
        titleText.setColor(Color::Green);
        titleText.setPosition(240, 520);
        titleText.setString("hi");


        while(play == true){
               
               
                while (window.pollEvent(event)){
                        if (event.type == Event::Closed) {
                                play = false;
                        }
                        if (Keyboard::isKeyPressed(Keyboard::Escape)) {
                                play = false;
                        }
                }




                        Character.move();
                       

                        window.clear();
                   
                        window.draw(Character.mainRect);
                        if (titleDisplay == true) {
                                window.draw(titleText);
                        }

                        window.display();
               
        }

        window.close();
        return 0;
}
« Last Edit: April 16, 2016, 06:27:56 pm by SSLukeY »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Can you provide the complete but minimal source code?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SSLukeY

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
it's the full code now sorry if it looks a bit messy i'm still a beginner,

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
it looks okay!,
are you sure you didn't use sf::Font instance elsewhere?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Does it also happen if you comment out your character class?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything