-1

我对这种方法有一个小问题,这是我的代码(我有更多代码,但这是给我错误的部分)

void ranCol( SDL_Surface sprite[], SDL_Rect paste)
{

        SDL_FillRect(sprite[y],NULL,temp);
        SDL_BlitSurface(sprite[y],&paste[y],rScreen(),NULL);
}

我收到 2 个错误

error C2664: 'SDL_FillRect' : cannot convert parameter 1 from 'SDL_Surface' to 'SDL_Surface *'
error C2664: 'randCol' : cannot convert parameter 2 from 'SDL_Surface *[50000]' to 'SDL_Surface []'

谁能帮我搞定这个工作?

编辑:这是代码以防有人想要编译它

    void randCol(int times, SDL_Surface* sprite[], SDL_Rect paste)
{
    int unsigned temp = 10101;//seed
    for(int y = 0;y < times;y++)
    {
        temp = temp*(y+y+1);
        temp = (temp^(0xffffff))>>2;
        //printf("%x\n",temp);
        SDL_FillRect(sprite[y],NULL,temp);
        SDL_BlitSurface(sprite[y],&paste[y],rScreen(),NULL);
    }
}
4

1 回答 1

1

您应该始终操作pointersSDL_Surface...将您的功能更改为

void ranCol( SDL_Surface* sprite, SDL_Rect paste)

我不知道你[y]来自哪里!如果它来自一个数组SDL_Surface,将单个SDL_Surface作为参数传递给函数,它会更清晰。

如果要传递一个 ARRAY 项,请使用以下签名:

void ranCol(SDL_Surface* sprite[], SDL_Rect paste[])

但是您仍然需要以y某种方式传递您的,无论是作为参数还是作为成员/全局。

于 2012-11-15T20:19:39.653 回答