SFML community forums

Help => General => Topic started by: SSLukeY on April 16, 2016, 05:07:54 pm

Title: Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.
Post by: SSLukeY on April 16, 2016, 05:07:54 pm
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;
}
Title: Re: Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.
Post by: eXpl0it3r on April 16, 2016, 05:59:23 pm
Can you provide the complete but minimal source code?
Title: Re: Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.
Post by: SSLukeY on April 16, 2016, 06:28:52 pm
it's the full code now sorry if it looks a bit messy i'm still a beginner,
Title: Re: Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.
Post by: Mortal on April 16, 2016, 07:25:19 pm
it looks okay!,
are you sure you didn't use sf::Font instance elsewhere?
Title: AW: Run-Time Check Failure #2 - Stack around the variable 'font' was corrupted.
Post by: eXpl0it3r on April 16, 2016, 07:33:44 pm
Does it also happen if you comment out your character class?