开发者

Organizing project files in Solution Explorer in Visual Studio

I'm making my first D3D simple game. My game uses many images.

This is my organization on disk:

MyGame
|
|-Debug
|-Release
|-Assets
  |-Others
  |-Images
|All cpp and h fiels here

If I launch my game from Visual Studio, thr game is working. But if I launch the game from Windows (by clicking the EXE file in the Release folder), I get an error that my application can't load images. This is because in my app I refer to those images like "Assets\Images\image.bmp".

How should I organize my project?

Now I have to make copy of the Assets folder in the Release folder and in the开发者_JS百科 main project folder.


I think your project is organized fine; my suggestion would be instead of relying on a certain directory structure, just have an app.config or other XML .config file setting, or perhaps a registry setting (but don't do that) or an environment variable (MY_GAME_ASSETS="C:\path\to\assets"), or perhaps even a command line parameter (MyGame.exe --assets-dir="c:\path\to\assets\") that you can set on launching your game; then you can point that at the right directory wherever it is.


Another possibility to @shelleybutterfly's answer is to always refer to images relatively, e.g. as "..\Assets\Images\abcde.bmp". Then when you deploy you could put your executable in the same kind of structure as long as the relative relationship is still the same.

e.g. Project:

MyGame
|-Debug
|-Release
|-Assets
  |-Others
  |-Images

e.g. Deployment:

C:\Program Files\MyGame
|-Bin (contains *.exe)
|-Assets
  |-Others
  |-Images
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜