由于路径不是绝对路径,无法在 ggez/rust 中加载图像

问题描述

我收到一个奇怪的错误,即 ggez 无法找到并加载我的图像文件。但即使是绝对路径仍然会出错。男的吗?

MyGame {
    carimage: Image::new(&mut ctx,"/home/arkadiusz/Dokumenty/competition-0008-gamedev/source/car_yellow_small_5.png").unwrap(),}

运行时错误

线程 'main' 在 Result::unwrap() 值上的 'call Err 处恐慌:ResourceNotFound("/home/arkadiusz/Dokumenty/competition-0008-gamedev/source/car_yellow_small_5.png",[( "/home/arkadiusz/Dokumenty/competition-0008-gamedev/source/target/release/resources",IOError(Os { code: 2,kind: NotFound,message: "No such file or directory" })),(" /home/arkadiusz/.local/share/competition8:gamedev",("/home/arkadiusz/.config/ Competition8:gamedev",message: "No such file or directory" }))])',src/main.rs:26:93

文件在那里:

$ ll /home/arkadiusz/Dokumenty/competition-0008-gamedev/source/
-rw-rw-r-- 1 arkadiusz arkadiusz   993 lip  7  2015 car_yellow_small_5.png

解决方法

不知何故它自己解决了。我不知道我是怎么做到的。对不起。

MyGame {
    carimage: Image::new(&mut ctx,"/car_yellow_small_5.png").unwrap(),}