Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [1.6 / Xcode 4.1] Weird loading resources issue  (Read 1745 times)

0 Members and 1 Guest are viewing this topic.

Dalius

  • Newbie
  • *
  • Posts: 2
    • View Profile
[1.6 / Xcode 4.1] Weird loading resources issue
« on: July 24, 2011, 01:22:11 am »
Hi all!

I just finished my first game (Pong) written using SFML 1.6 C++ and Xcode 4.1. It currently uses one font (.ttf) and two audio files (.wav). Everything works perfectly when I run the game from within Xcode using the 'Run' command.

However, when I run the .app file from outside of Xcode, the fonts and sounds are not loading! The title screen which uses the font is completely blank, although it technically works (and by works I mean it doesn't crash and is still polling for user input). The game screen (using the audio files) plays normal as well, just without the sound.

The resource files are in the same folder as the .app file so I am not sure what I am doing wrong. Any help would be appreciated!  :D

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
[1.6 / Xcode 4.1] Weird loading resources issue
« Reply #1 on: July 24, 2011, 01:44:05 am »
I think your resources fail to load. You should check if that works, the LoadFromFile() functions have a return value for a reason :P

The working directory is probably different when started inside the IDE and directly. I think it should work when the path is specified relative to the application, although I'm not sure how this works on Mac exactly.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
[1.6 / Xcode 4.1] Weird loading resources issue
« Reply #2 on: July 24, 2011, 02:25:07 am »
You're most probably using SFML 2.0, not SFML 1.6.

With SFML 1.6 the paths are always relative to the Resources folder in your bundle application. It doesn't change if you launch your app from Xcode or the Finder.

With SFML 2.0 the behavior isn't the same : there's nothing done concerning the start point of your paths. Thus from Xcode it's the folder where your app is located, and from the Finder it's the root directory.
Want to play movies in your SFML application? Check out sfeMovie!

Dalius

  • Newbie
  • *
  • Posts: 2
    • View Profile
[1.6 / Xcode 4.1] Weird loading resources issue
« Reply #3 on: July 24, 2011, 03:25:20 am »
Quote from: "Ceylo"
With SFML 1.6 the paths are always relative to the Resources folder in your bundle application. It doesn't change if you launch your app from Xcode or the Finder.


I am using SFML 1.6 and this was the problem. I guess I was not aware of how .app files loaded its resources. D'oh! Thank you very much for suggesting that, my problem has been solved. Now to compile Windows and Linux binaries...  :D