The working directory on MacOSX

Hi,

I use a folder called “data” to contain all the game’s graphics and
sounds. In the MacOSX build this folder is copied into the Resources
folder of the application bundle. Then I load my images using a
relative path like this:

IMG_load("data/laser.png");

…and it works just fine when running from the Finder, because the
"working directory" at runtime is set to the Resources folder. This is
good.

However, when I run the game from within ProjectBuilder my data files
cannot be located because the working directory is set to the "build"
folder (i.e., the folder containing the application).

From looking around on the web
(http://www.crissman.net/macgamewiki/index.php/
WhyCantMyProgramFindMyFile) it appears this is normal behavior. And I
see in SDLMain.m that this is the reason why:

 [self setupWorkingDirectory:gFinderLaunch];

Is there some practical reason the working directory is set differently
for Finder launches versus running in PB?

  • Scott Lahteine
    Botfly Games