我有一個名爲SpriteCollection的類,我用SDL加載圖像。這個班有一個屬性叫:數組分配
SDL_Surface* sprites[];
我認爲這是正確的(雖然我不確定)。在同一個類我有一個方法:
void addNewSprite(SDL_Surface* sprite){
this->sprites[n_sprites+1] = new SDL_Surface;
this->sprites[n_sprites+1] = IMG_Load("spritepath.jpg");
this->n_sprites++;
}
,另一個檢索SDL_Surface在屏幕上繪製:
SDL_Surface getSprite(int sprite_index){
return this->sprites[sprite_index];
}
並以我使用的屏幕上繪製:
Draw(x_position, y_position, this->sprite->getSprite[0], screen);
我正在加載圖片;一切正常,但IDE返回關於指針和SDL_Surface
和SDL_Surface *
之間轉換的錯誤。
我在做什麼錯?
編輯:錯誤消息:
E:\cGame.cpp|71|error: cannot convert `SDL_Surface' to `SDL_Surface*' for argument `1' to `int SDL_UpperBlit(SDL_Surface*, SDL_Rect*, SDL_Surface*, SDL_Rect*)'|
請發佈您正在收到的* exact *錯誤消息。 – 2012-03-18 15:58:34