如何获取精灵的实际位置并在 C++ 和 sfml 中打印
How to get actual position of sprite and print it in c++ and sfml
我正在尝试制作简单的 2d 游戏。我需要在控制台中打印这个。我尝试这样做,但没有用。
sf::Vector2f position = entity.getPosition();
std::cout << position << endl;
我也试过了
p_pos = entity.getPosition();
std::cout << _p_pos << endl;
还是不行。
...it's not working...
对我们没有帮助。请post完整的错误。
无论如何,我假设默认情况下未定义 operator<<(std::ostream&, const sf::Vector2&)
。因此,可以单独打印vector的坐标:
sf::Vector2f position = entity.getPosition();
std::cout << position.x << " " << position.y << "\n";
我正在尝试制作简单的 2d 游戏。我需要在控制台中打印这个。我尝试这样做,但没有用。
sf::Vector2f position = entity.getPosition();
std::cout << position << endl;
我也试过了
p_pos = entity.getPosition();
std::cout << _p_pos << endl;
还是不行。
...it's not working...
对我们没有帮助。请post完整的错误。
无论如何,我假设默认情况下未定义 operator<<(std::ostream&, const sf::Vector2&)
。因此,可以单独打印vector的坐标:
sf::Vector2f position = entity.getPosition();
std::cout << position.x << " " << position.y << "\n";