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

Author Topic: Error loading sprite.  (Read 2398 times)

0 Members and 1 Guest are viewing this topic.

Girby2K11

  • Newbie
  • *
  • Posts: 24
    • View Profile
Error loading sprite.
« on: April 10, 2011, 09:17:53 pm »
Hi, i am new to this forum and currently TRYING to learn SFML.

Anyway when i type in the code for loading a sprite, and then tell teh program where to find the picture sf::Image Image;
if (!Image.LoadFromFile("gun.png")) when i compile and run it says this error failed to load image "gun.png". reason unable to open file? can anyone help me with this. Thanks  :evil:
I'm tring to learn SFML Help? Collision?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Error loading sprite.
« Reply #1 on: April 10, 2011, 09:22:06 pm »
The image is probably not in the executable directory or has another name.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

JAssange

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Error loading sprite.
« Reply #2 on: April 11, 2011, 03:34:25 am »
The image must be in the folder with the exe or the folder you set as the working directory in your debugger's options if you specify the name without a path. It can't magically find images in your Pictures folder or that are up 3 directories.

drakelord

  • Newbie
  • *
  • Posts: 22
    • View Profile
Error loading sprite.
« Reply #3 on: April 14, 2011, 07:50:46 pm »
Or, if for some odd reason you need to, you can also use absolute paths.  I would highly not recommend this though.