When creating a new image with Gosu I get a very descriptive (sarcasm) "RuntimeError: Unknown Error"gist
I'm new to Gosu so I apologise if this question is stupid but, I'm not sure what I'm doing wrong here.
Here's the repo of the code I'm working on, the issue happens in assets.rb @ line 19github
Just a guess, but it's probably not finding the PNG file. You should generate an absolute filename based on the path of the script (e.g. using __FILE__).
This seems a bit weird to me since in the Gosu examples (specifically CaptRuby
) he uses relative pathing just fine. I'll give it a try and edit this post with results. I just wish the Error message was a little more descriptive because I have 0 clue what "Unknown Error" is supposed to convey.
EDIT: Didn't work :( I even have it puts the dir name and its super valid (RubyMine even links it for me so when I click the link I puts it correctly opens that file. What's weirder is that your method seems to work in IRB but not RubyMine or by running the script directly.gist for error from rubyminegist from irb
Specific code that is giving me trouble is now line 23github
Well, I did say it was a guess ;)
I think that error comes directly from the library (FreeImage?) used to load the image. If it's opening the right file, that error usually means it can't load the file, for some reason, e.g. unsupported (sub)format, damaged file, etc., but I've downloaded both block.png and tile.png, and a minimal program loads and displays either one perfectly fine (even from a relative path). I'm out of ideas :/
EDIT: jlnr beat me to it on FreeImage, and found the real problem :P
That's a libfreeimage error, the only one the library ever seems to return :)
As RunnerPack has pointed out, it's usually caused by the image file not being there. You are trying to load
"block_shade,png" with a comma instead of a dot.
You can use relative filenames just fine, but you need to be sure to run the game from the right directory if you do. E.g. you cannot
content and then run
Using paths relative to
__FILE__ can protect you against this. It all depends on how you distribute your game, I guess.
You are totally right I'm a derp. I misread the error line and thought it was still happening on line 23. Thanks for the hand holding.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill