SDL 方法,参数转换
SDL method , parameter convertion
我对这种方法有一个小问题,这是我的代码(我有更多的代码,但这是给我错误的部分)
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("%xn",temp);
SDL_FillRect(sprite[y],NULL,temp);
SDL_BlitSurface(sprite[y],&paste[y],rScreen(),NULL);
}
}
您应该始终操作pointers
以SDL_Surface
... 将函数更改为
void ranCol( SDL_Surface* sprite, SDL_Rect paste)
我不确定你的[y]
从何而来! 如果它来自 SDL_Surface
数组,将单个SDL_Surface
作为参数传递给函数,它会更清晰。
如果要传递项目数组,请使用以下签名:
void ranCol(SDL_Surface* sprite[], SDL_Rect paste[])
但是您仍然需要以某种方式传递y
,无论是作为参数还是作为成员/全局。
相关文章:
- C++转换参数初始化问题
- C2664 无法从'initializer list'转换参数
- 隐式可转换参数,但属于引用类型
- 传递到函数(C )时转换参数
- 了解错误 C2664:无法转换参数 1
- 错误 C2664:无法从'NvPhysicalGpuHandle'转换参数 1
- Unicode 字符问题/转换参数
- 在运行时根据某些元数据强制转换参数包值
- 错误 C2664:"errno_t wcstombs_s(size_t *,字符 *,size_t,常量 wchar_t *,size_t)":无法转换参数 4
- 错误C2664:无法转换参数错误
- 无法转换参数错误
- Boost.python自动转换参数
- "尝试升级使用已弃用的转换参数指定的输入文件"是什么意思?
- 是否可以在函数模板中转换参数C++?
- 错误C2664:无法转换参数(指纹传感器检测)
- 无法转换参数 - 模板错误
- 编译zxing时,Libconv无法转换参数
- C++ 无法转换参数
- std::p air<_Ty1,_Ty2>::p air<_Ty1,_Ty2>& 无法转换参数
- 无法转换参数-转换丢失限定符