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

Author Topic: Problem with strings in SFML 2.0  (Read 1233 times)

0 Members and 1 Guest are viewing this topic.

ZakMan

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Problem with strings in SFML 2.0
« 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]

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Problem with strings in SFML 2.0
« Reply #1 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
Back to C++ gamedev with SFML in May 2023

 

anything