I'm trying to add a spritesheet to my Ggez game, and getting the following error when running cargo run
:
Error: ResourceNotFound("/sprites.png", [("/home/pablo/Dev/rust-game/target/debug/resources", IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" })), ("/home/pablo/.local/share/our_game", IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" })), ("/home/pablo/.config/our_game", IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" }))])
From the docs I thought I just had to put my sprites.png in the resources
folder, which I did:
❯ ls resources/
sprites.png
But it doesn't seem to be looking in that folder, instead it looks in .../target/debug/resources
. I guess that makes sense, as that seems to be the folder where the build is placed (I'm new to rust, so just taking a guess here). That folder does not exist:
❯ ls target/debug/resources
ls: cannot access 'target/debug/resources': No such file or directory
For gezz I found cargo-resource-root
but that option no longer exists it seems. And for Rust the include
field in Cargo.toml
also didn't actually make any difference. Are there other things I can try to either let Ggez know to look in the right place, or to let Rust know to include those files?
I found a solution!
It's possible to manually add additional folder it looks for for resources, and the docs mention this can be useful for debugging. So I did what the docs told me, and added the following in my
main()
:That seems to have worked, at least it's not crashing any more saying it can't find the file.