En gissning: Den gillar inte char dir[] = "\data\textures\"; Prova med detta istället:
char dir[] = "\\data\\textures\\";
5 svar · 225 visningar · startad av Alpha II
Förstår inte varför jag får fel :l
void LoadGame()
{
// Texturer
char dir[] = "\data\textures\";
LoadTGA(textures[TEX_SPACESHIP],dir + "spaceship.tga");
LoadTGA(textures[TEX_ASTEROID], dir + "asteroid.tga");
LoadTGA(textures[TEX_MISSILE], dir + "missile.tga");
}
Fel ~
Error E2380 load.cpp 4: Unterminated string or character constant in function LoadGame()
Error E2141 load.cpp 5: Declaration syntax error in function LoadGame()
Error E2085 load.cpp 6: Invalid pointer addition in function LoadGame()
Error E2034 load.cpp 6: Cannot convert 'TextureImage' to 'TextureImage *' in function LoadGame()
Error E2342 load.cpp 6: Type mismatch in parameter 'texture' (wanted 'TextureImage *', got 'TextureImage') in function LoadGame()
Error E2085 load.cpp 7: Invalid pointer addition in function LoadGame()
Error E2034 load.cpp 7: Cannot convert 'TextureImage' to 'TextureImage *' in function LoadGame()
Error E2342 load.cpp 7: Type mismatch in parameter 'texture' (wanted 'TextureImage *', got 'TextureImage') in function LoadGame()
Warning W8004 load.cpp 9: 'dir' is assigned a value that is never used in function LoadGame()
En gissning: Den gillar inte char dir[] = "\data\textures\"; Prova med detta istället:
char dir[] = "\\data\\textures\\";
Error E2085 load.cpp 5: Invalid pointer addition in function LoadGame()
Error E2034 load.cpp 5: Cannot convert 'TextureImage' to 'TextureImage *' in fun
ction LoadGame()
Error E2342 load.cpp 5: Type mismatch in parameter 'texture' (wanted 'TextureIma
ge *', got 'TextureImage') in function LoadGame()
Error E2085 load.cpp 6: Invalid pointer addition in function LoadGame()
Error E2034 load.cpp 6: Cannot convert 'TextureImage' to 'TextureImage *' in fun
ction LoadGame()
Error E2342 load.cpp 6: Type mismatch in parameter 'texture' (wanted 'TextureIma
ge *', got 'TextureImage') in function LoadGame()
Error E2085 load.cpp 7: Invalid pointer addition in function LoadGame()
Error E2034 load.cpp 7: Cannot convert 'TextureImage' to 'TextureImage *' in fun
ction LoadGame()
Error E2342 load.cpp 7: Type mismatch in parameter 'texture' (wanted 'TextureIma
ge *', got 'TextureImage') in function LoadGame()
Warning W8004 load.cpp 9: 'dir' is assigned a value that is never used in functi
on LoadGame()
void LoadGame()
{
// Texturer
char dir[] = "\\data\\textures\\";
LoadTGA(textures[TEX_SPACESHIP],dir + "spaceship.tga");
LoadTGA(textures[TEX_ASTEROID], dir + "asteroid.tga");
LoadTGA(textures[TEX_MISSILE], dir + "missile.tga");
}
Strängarna borde du slå ihop med:
strcat( dir, "spaceship.tga" )
vilket du kan göra inne i funktionsanropen till "LoadTGA". Den andra delen kan jag inte hjälpa så mycket med eftersom jag inte vet vad "TextureImage" är, men tydligen ska du skicka en pekare till en sådan. Nu skickar du tydligen hela structen i sig själv.
dir är en C-sträng. Inte en string. Du kan inte använda plusoperatorn på en C-sträng på det där sättet.
Kolla lite på strcpy() och strcat()...
UlfT var först såg jag. Men kom ihåg att du inte kan använda den char-array (dir) du har nu med strcat.
När du deklarerar den såhär:
char dir[] = "\\data\\textures\\";
så allokeras bara precis så mycket minne som strängen behöver.
För att få plats med filnamnet efter så får du skapa en temporär char-array som är tillräckligt stor för att få plats med alla tecken.
Funkar utmärkt! Iaf den delen :D
Programmet kraschar när man startar det :( Men det problemet ligger nog någon annanstans...