我想做一个程序,如果你选择一个曲面,它会被放到selectedPiece变量中,但我使用的是SDL_PointInRect。它给出了这个错误“的参数类型“SDL_Surface”是不兼容的参数类型“const SDL_Rect””你知道替代PointInRect是兼容的表面?
SDL_Surface* selectedPiece;
std::list<SDL_Surface*> pieces;
bool leftClick;
if (SDL_MOUSEBUTTONDOWN)
{
if (!leftClick && windowEvent.button.button == SDL_BUTTON_LEFT)
{
leftClick = true;
for (auto surface : pieces
{
if (SDL_PointInRect(&mousePos, surface)) //<<<--- the sdl point in rect isnt compatible with the surface
{
selectedPiece = surface;
}
}
}
}
1条答案
按热度按时间jk9hmnmh1#
因为你
SDL_BlitSurface(imageSurface, NULL, windowSurface, NULL);
,这意味着目标矩形的左上角在(0,0)。适当的检查将是: