SDL方法,参数转换

时间:2012-11-15 20:17:58

标签: c++ methods sdl

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

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);
    }
}

1 个答案:

答案 0 :(得分: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,无论是作为参数还是作为成员/全球传递。