简体   繁体   English

SFML 无法打开文件

[英]SFML unable to open file

I used SFML to create ARKANOID.我使用 SFML 创建 ARKANOID。 If I run in debug mode, it will run normally.如果我在调试模式下运行,它将正常运行。 But when I run in Release mode, it can't read the image file.但是当我在发布模式下运行时,它无法读取图像文件。

In the Command window, the output is as follows: Failed to load image "?? "?在命令 window 中,output 如下: 无法加载图像“??”? ". Reason: Unable to open file Failed to load image "es/ball.png ". Reason: Unable to open file Failed to load image "es/ball.png "? ". ”。原因:无法打开文件无法加载图像“es/ball.png”。原因:无法打开文件无法加载图像“es/ball.png”?“。 Reason: Unable to open file Failed to load image "es/ball.png "?原因:无法打开文件加载图片“es/ball.png”失败? ". Reason: Unable to open file "。原因:无法打开文件

I've tried the absolute path and I've tried the relative path.我试过绝对路径,也试过相对路径。 And i also tired loadFromFile("images/ball");我也厌倦了 loadFromFile("images/ball");

please help me请帮我

You need to put the PNG file in the directory where main.cpp is located.您需要将PNG文件放在main.cpp所在的目录中。 You can put it in both the debug directory and the release directory.您可以将它放在调试目录和发布目录中。 Also note the file extension in the directory (.png or.jpg) and edit the code.还要注意目录中的文件扩展名(.png 或 .jpg)并编辑代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM