SDL ゲームにカスタム カーソルを実装しました。画面を横切って移動すると、右と下に好きなだけ移動できます。ただし、カーソルは ledt または上部の壁を超えません。現在の値と値を使用SDL_GetMouseState
して渡しています。x
y
サーフェスをその位置に移動できるようにするにはどうすればよい(-5, 0)
ですか?
ここにいくつかのコードがあります:
typedef struct {
SDL_Surface *image;
SDL_Rect frame;
} Cursor;
void moveCursor(Cursor *cursor) {
Sint16 *x = &cursor->frame.x;
Sint16 *y = &cursor->frame.y;
Uint16 cursorWidth = cursor->frame.w;
Uint16 cursorHeight = cursor->frame.h;
SDL_GetMouseState((int *)x, (int *)y);
cursor->frame.w = cursorWidth;
cursor->frame.h = cursorHeight;
SDL_Rect temporaryFrame = cursor->frame;
SDL_BlitSurface(cursor->image, NULL, bufferSurface.surface, &temporaryFrame);
}