This site requires JavaScript, please enable it in your browser!
Greenfoot back
lehrerfreund
lehrerfreund wrote ...

2021/10/26

Accessing files on macOS

lehrerfreund lehrerfreund

2021/10/26

#
Hi, in the scenario Atlas the wizard there are some files accessed, e.g. a spritesheet, via:
SpriteSheet playerSheet = new SpriteSheet(".\\res\\atlas\\playersprite.png", 5, 8, 32, 48);
When I run this on macOS it does not work (error: javax.imageio.IIOException: Can't read input file!). I tried things like
/res/atlas/…
but this did not work. How do I have to call the paths on macOS?
nccb nccb

2021/11/2

#
The backslash is Windows-only so it won't work on Mac, you're right. I would have thought that "./res/atlas/..." should be the equivalent (note the leading dot).
lehrerfreund lehrerfreund

2021/11/8

#
Yes, thanks, this seems to be working! (Although I have still problems getting the scenario to run, probably this one makes problems:
            mapTokens[i] = Utils.loadFileAsString(layerPaths[i]).split("\\s");
… but this is another topic …)
You need to login to post a reply.