在我的项目中,我有一个Animator类,它有一个加载所有精灵的方法。
SDL_Texture*
Animator::CF_createImage_Load( SDL_Renderer* FP_renderer , std::string FV_path ,Uint8 FV_brC1,Uint8 FV_brC2,Uint8 FV_brC3, SDL_Window* window )
{
SDL_Surface* loadSurface = IMG_Load(FV_path.c_str());
SDL_Texture* texture = SDL_CreateTextureFromSurface( FP_renderer , loadSurface );
SDL_SetTextureColorMod(texture, FV_brC1, FV_brC2, FV_brC3);
SDL_SetTextureBlendMode( texture , SDL_BLENDMODE_ADD );
return texture;
SDL_FreeSurface( loadSurface );
SDL_DestroyTexture( texture );
}
因此,如果我在 IDE 中运行它,它会正确加载所有精灵而不会出现任何错误。我刚刚检查了所有调试指针,所有这些都正常,每个图像都按照我所说的正确显示,但仅在 IDE 中。如果我构建它并尝试在 IDE 之外运行可执行文件(在发布或调试文件夹中),则根本不会显示图像。
还有一件事。字体在 IDE 之外正确加载,但 Sprites 没有。