我正在使用预先构建的库,为了让我加载纹理并显示它我必须使用此代码.我正在寻找加载多个文件并将它们存储为struct数组,以便可以调用和显示它们.我一直收到这个错误:
没有合适的从
std字符串到const char*的转换函数
在尝试加载以下部分时.
for (int i=0; i<CUTSCENE; i++)
{
stringstream s;
int fileNum = i+1;
string FirstPart = "Textures/GameVideos/Game (";
string LastPart = ").png";
s << FirstPart << fileNum << LastPart << endl;
string fullfileName;
s >> fullfileName;
cutSceneMain[i]->texture = new Texture2D();
cutSceneMain[i]->texture->Load(fullfileName, false);
cutSceneMain[i]->sourceRect = new Rect(0.0f, 0.0f, 700, 700);
cutSceneMain[i]->position = new Vector2(0.0f, 0.0f());
}
Run Code Online (Sandbox Code Playgroud)
问题很可能与您调用的方式有关Load,修复方法是使用fullfileName.c_str():
cutSceneMain[i]->texture->Load(fullfileName.c_str(), false);
^^^^^^^
Run Code Online (Sandbox Code Playgroud)
Load 要求 const char*
| 归档时间: |
|
| 查看次数: |
3562 次 |
| 最近记录: |