bar*_*des 4 c++ sdl cross-platform relative-path
我正在用SDL编写一个小游戏,文件的结构如下:
"src/game /"同时包含.h和.cpp源文件.
"data /"有游戏文件,如地图,tilesets,sprite等......
例如,我将使用以下代码加载精灵.
spriteLib.loadSprite("data/sprites/sprite-ghost.bmp");
Run Code Online (Sandbox Code Playgroud)
要将此字符串转换为绝对路径,我在函数的前4行中包含这些行:
SSprite CSpriteLib::loadSprite(std::string file)
{
//Converting the file path
char converted[128];
realpath(file.c_str(),converted);
file = converted;
Run Code Online (Sandbox Code Playgroud)
但是这样程序只能在liux下编译...所以如果有人知道另一种方法,我会很感激.