我使用的是最新版本的SDL,enum SDL_WINDOWEVENT似乎缺失了
在SDL_Events.h中,SDL_Events的定义是:
/** General event structure */
typedef union SDL_Event {
Uint8 type;
SDL_ActiveEvent active;
SDL_KeyboardEvent key;
SDL_MouseMotionEvent motion;
SDL_MouseButtonEvent button;
SDL_JoyAxisEvent jaxis;
SDL_JoyBallEvent jball;
SDL_JoyHatEvent jhat;
SDL_JoyButtonEvent jbutton;
SDL_ResizeEvent resize;
SDL_ExposeEvent expose;
SDL_QuitEvent quit;
SDL_UserEvent user;
SDL_SysWMEvent syswm;
} SDL_Event;
我知道wiki有一个SDL_WINDOWEVENT
// --------------------------------------------- -----------------------------------
编辑以澄清问题
如果查看提供的链接,示例代码会给出
void PrintEvent(const SDL_Event * event)
{
if (event->type == SDL_WINDOWEVENT) {
switch (event->window.event) {
case SDL_WINDOWEVENT_SHOWN:
fprintf(stderr, "Window %d shown", event->window.windowID);
break;
// snip
}
我的代码
SDL_Event sdlEvent = {0};
while(SDL_PollEvent(&sdlEvent))
{
if(sdlEvent.type == SDL_QUIT)// || isTriggered(SDLK_ESCAPE))
System::getEventManagerGlobal().broadcastEvent( Event("QUIT") );
if(sdlEvent.type == SDL_WINDOWEVENT)
{
if(sdlEvent.window.event == SDL_WINDOWEVENT_MOVED)
{
// snip
}
}
}
错误C2065:'SDL_WINDOWEVENT':未声明的标识符 错误C2039:'window':不是'SDL_Event'的成员 sdl_events.h(227):查看'SDL_Event'的声明 错误C2228:'。event'的左边必须有class / struct / union 错误C2065:'SDL_WINDOWEVENT_MOVED':未声明的标识符
答案 0 :(得分:0)
我发现了我遇到的问题 - Joachim和user1202136让我觉得
我误解了我正在使用的SDL版本,这解释了为什么这些方法不存在..