SFML community forums

Help => Graphics => Topic started by: ZakMan on December 02, 2012, 02:08:02 pm

Title: Problem with strings in SFML 2.0
Post by: ZakMan on December 02, 2012, 02:08:02 pm
Hi! I'm trying to display Mouse coordinates in the render window. Here's my code:
...
sf::Font MyFont;

    if (!MyFont.loadFromFile("arial.ttf"))
    {
        return 1;
    }

    sf::Text myPos;
    std::string str;

while (window.pollEvent(event))
        {
         if (event.type == sf::Event::MouseMoved)
            {
                str=event.mouseMove.x+" "+event.mouseMove.y;
                myPos.setString(str);
                myPos.setFont(MyFont);
                myPos.setCharacterSize(20);
                myPos.setColor(sf::Color::Red);
                myPos.setPosition(0,0);
                std::cout<<str;
            }
        }
...
 

...but instead of the coordinates the string gets some weird system messages about problems with relocation:



[attachment deleted by admin]
Title: Re: Problem with strings in SFML 2.0
Post by: FRex on December 02, 2012, 02:21:03 pm
Quote
Computer science is the art of transporting information from smart people in front of stupid machines to stupid people in front of smart machines...
This has been adressed and is a fundamental error in a powerful language such as c++.
http://en.sfml-dev.org/forums/index.php?topic=9735.msg66550#msg66550