- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在互联网和这里搜索过,只找到了 1 个很好的帖子 SDL_RenderCopy with an array of Rectangles 。 (据我所知)没有答案,但我的问题与那里相同。有什么办法可以做到这一点吗?
SDL_RenderCopy(renderer, texture, &rects[index], &sprPos);
这是调试的内容:
Error 1 error C2664: 'int SDL_RenderCopy(SDL_Renderer *,SDL_Texture *,const SDL_Rect *,const SDL_Rect *)' : cannot convert argument 3 from 'SDL_Rect **' to 'const SDL_Rect *' c:\users\kushnirenko\documents\visual studio 2013\projects\sdl_project\sdl_project\main.cpp 96 1 SDL_Project
2 IntelliSense: argument of type "SDL_Rect **" is incompatible with parameter of type "const SDL_Rect *" c:\Users\kushnirenko\Documents\Visual Studio 2013\Projects\SDL_Project\SDL_Project\main.cpp 96 37 SDL_Project
最佳答案
我解决了这个问题。有一种方法可以将数组设置为 SDL_RenderCopy。这是:
// Sprites atlas regions
SDL_Rect left = { sprite * 32, 32, 32, 32 };
SDL_Rect right = { sprite * 32, 64, 32, 32 };
SDL_Rect up = { sprite * 32, 96, 32, 32 };
SDL_Rect down = { sprite * 32, 0, 32, 32 };
SDL_Rect leftIdle = { 32, 32, 32, 32 };
SDL_Rect rightIdle = { 32, 64, 32, 32 };
SDL_Rect upIdle = { 32, 96, 32, 32 };
SDL_Rect downIdle = { 32, 0, 32, 32 };
// End of sprite atlas
sprPos = { x, y, 32, 32 };
spritesCoords[0] = left;
spritesCoords[1] = right;
spritesCoords[2] = up;
spritesCoords[3] = down;
spritesCoords[4] = leftIdle;
spritesCoords[5] = rightIdle;
spritesCoords[6] = upIdle;
spritesCoords[7] = downIdle;
sprFrame = spritesCoords[spriteIndex]; // This is solutuion.
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, &sprFrame, &sprPos);
SDL_RenderPresent(renderer);
关于c++ - SDL_RenderCopy() 不适用于数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27786360/
我很确定这一点也不意外,我可能误解了一些东西。我正在尝试调用其中一个重载的构造函数: SDL_RenderCopy(SDL_Renderer*, SDL_Texture*, SDL_Rect*, SD
我在互联网和这里搜索过,只找到了 1 个很好的帖子 SDL_RenderCopy with an array of Rectangles 。 (据我所知)没有答案,但我的问题与那里相同。有什么办法可以
我正在调用 SDL_RenderCopy,它被调用并正常返回,但没有向窗口绘制任何内容。编辑以使问题和代码更清晰。我在想我可能会尝试使用超出其范围的东西,因此无法调用它,但这不会产生任何错误,所以我不
我是 C++ 的新手,我正在使用 SDL 2.0 学习它。尝试使用我的 Sprite 类绘制 Sprite 时遇到以下错误: 在 SDDDDL2.exe 中的 0x000000006C793659 (
这是我的 .cpp 文件: #include #include #include bool runningOnEmpty = false; const char* title; int x
这让我很难过.. 我有一个非常简单的 SDL2 程序。 它有一个包含 3 个 SDL_Texture 指针的数组。 这些纹理填充如下: SDL_Texture *myarray[15]; SDL_Su
我正在使用 SDL2 编写光线转换游戏。绘制地板时,我需要按像素调用 SDL_RenderCopy。这会导致帧率下降到 10 fps 以下的瓶颈。我正在寻找性能提升,但似乎找不到。 以下是性能下降的粗
我正在使用 SDL2 编写光线转换游戏。绘制地板时,我需要按像素调用 SDL_RenderCopy。这会导致帧率下降到 10 fps 以下的瓶颈。我正在寻找性能提升,但似乎找不到。 以下是性能下降的粗
我是一名优秀的程序员,十分优秀!