我在 Visual Studio 上使用 SFML,并在资源文件中放置了一个名为“stone.png”的文件。
#include <SFML/Graphics.hpp>
int WIDTH = 500;
int HEIGHT = 500;
int main() {
sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "SFML Game");
window.setFramerateLimit(60);
sf::Event e;
sf::Texture t1, t2, t3, t4;
t1.loadFromFile("stone.png");
sf::Sprite sBackground(t1);
while (window.isOpen()) {
while (window.pollEvent(e)) {
if (e.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
window.draw(sBackground);
}
return 0;
}
当我运行此代码时,出现上述错误。