0
最近我遇到了一个问题。我不能让sf :: Text工作。不知道为什么,字体似乎正在加载。 下面的代码:不能得到sf ::文本工作
#include <SFML/Graphics.hpp>
int main()
{
// Create the main window
sf::RenderWindow app(sf::VideoMode(800, 600), "SFML window");
sf::Font font;
sf::Text text;
if(!font.loadFromFile("/usr/share/fonts/TTF/arial.ttf"))
std::cout<<"Error";
text.setFont(font);
text.setCharacterSize(30);
text.setColor(sf::Color::Blue);
// Start the game loop
while (app.isOpen())
{
// Clear screen
app.clear();
// Draw the sprite
app.draw(text);
// Update the window
app.display();
}
return 0;
}
有什么建议?
不知道任何有关SFML的知识,但是您是否确实在某处设置了“text”文本?我只看到字体和颜色。 – Nabla
尝试'text.setString(“Hello World”);'在你的游戏循环之前的某个地方 – Machtl
啊,我很愚蠢。对不起,浪费你的时间xD – Romen