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

Author Topic: How do I load relatively  (Read 108 times)

0 Members and 1 Guest are viewing this topic.

BarryLarry17Jr

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
How do I load relatively
« on: July 26, 2020, 03:41:07 pm »
Right now i am loading a texture from this directory:

arrow.loadFromFile("/Users/oliverswan/Desktop/SFML/Coin\ Flip/Coin\ Flip/arrow.png");

But I want to load from my project folder which is the first Coin Flip Folder. Help!

Paul

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Re: How do I load relatively
« Reply #1 on: July 27, 2020, 01:00:08 pm »
Nice chaos. Don't use system paths and don't put files on your desktop.

Create folder on C:\ like "C:\Dev", put all your projects there, then put your assets (graphics, audio..) into specific project folder and use relative path, which will be just name of file or something like "Textures/texture.png" if you create extra folders.

Hapax

  • Hero Member
  • *****
  • Posts: 3017
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: How do I load relatively
« Reply #2 on: July 28, 2020, 12:00:53 am »
If the working directory is (definitely) the first coin flip folder, you can use the rest of the path as a relative one: "Coin Flip/arrow.png". If the working directory is the second coin flip folder, the relative path would just be the file: "arrow.png".
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter