【发布时间】:2011-05-29 05:28:00
【问题描述】:
我正在用 SDL 编写一个小游戏,文件的结构如下:
“src/game/”同时拥有 .h 和 .cpp 源文件。
"data/" 包含游戏文件,如地图、图块集、精灵等...
以加载精灵为例,我将使用以下代码。
spriteLib.loadSprite("data/sprites/sprite-ghost.bmp");
要将此字符串转换为绝对路径,我在函数的前 4 行中有这些行:
SSprite CSpriteLib::loadSprite(std::string file)
{
//Converting the file path
char converted[128];
realpath(file.c_str(),converted);
file = converted;
但是这种方式程序只能在 liux 下编译,所以......如果有人知道另一种方法,我将不胜感激。
【问题讨论】:
标签: c++ cross-platform sdl relative-path