Tuesday, September 21, 2010

Image Loading Bug Fixed!

Since the beginning of the project, a minor bug has been nagging at me:  Images that come built in to the MHFramework engine (in this case, the splash screen) have not been loading when running the game as an executable JAR file.  I have discovered the source of the problem.  For future reference, here's the fix:
 
I was loading images like this, using a relative path from the image loading code to the location of the image files:
MHResourceManager.loadImage("../images/imageFile.jpg");

This approach works great as long as you aren't running from a JAR file.  However, if the images are contained in a JAR file, you must use the entire path name beginning with a slash, like this:
MHResourceManager.loadImage("/mhframework/images/imageFile.jpg");

Now, no matter how we run the program, we have the comforting familiarity of the good old MHFramework splash screen.

This issue is now resolved and will be removed from the issue tracking spreadsheet.  Consequently, this also means a new version number for the engine, but I will address that later after I officially check in some other recent upgrades.

No comments:

Post a Comment