i using irrwizard in my project,for using irrlicht gui,i did modify the code:
in class GameState,
displace
Code: Select all
virtual void MouseEvent(CGameManager* pManager,const SEvent& event) = 0;
virtual void KeyboardEvent(CGameManager* pManager,const SEvent& event) = 0;
Code: Select all
virtual bool OnEvent(CGameManager* pManager,const SEvent& event) = 0;
so
Code: Select all
bool CGameManager::OnEvent(const SEvent& event)
{
if (!m_pDriver)
return false;
if (event.EventType == EET_KEY_INPUT_EVENT)
{
m_pGameState->OnEvent(this,event);
}
else if (event.EventType == EET_MOUSE_INPUT_EVENT)
{
m_pGameState->OnEvent(this,event);
}
else if (event.EventType == EET_GUI_EVENT)
{
m_pGameState->OnEvent(this,event);
}
return true;
}
bool CGameMenuState::OnEvent(CGameManager* pManager,const SEvent& event)
{
if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown == false)
{
if (event.KeyInput.Key == KEY_ESCAPE)
{
pManager->getDevice()->closeDevice();
}
else if ( event.KeyInput.Key == KEY_F1)
{
ChangeState(pManager, CGameStateLoad01::Instance());
}
}
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
switch(id)
{
case 101:
ChangeState(pManager, CGameStateLoad01::Instance());
break;
case 102:
break;
case 103:
ChangeState(pManager, CGameCreditsState::Instance());
break;
case 104:
pManager->getDevice()->closeDevice();
break;
default:
break;
}
break;
default:
break;
}
}
return false;
}
void CGameMenuState::Init(CGameManager * pManager)
{
CGameState::Init(pManager);
LoadMouseCursor(pManager);
// to display mouse crusor
pManager->getDevice()->getCursorControl()->setVisible(true);
m_pIntroImage = pManager->getGUIEnvironment()->addImage(irr::core::rect< irr::s32 >(256,30,1024,768));
m_pIntroImage->setImage(pManager->getDriver()->getTexture("media/intro.jpg"));
m_pPlayButton = pManager->getGUIEnvironment()->addButton(core::rect< irr::s32 >(400,448,580,518),0,GUI_ID_PLAY_BUTTON);
m_pPlayButton->setImage(pManager->getDriver()->getTexture("media/buttons/but_play.bmp"));
m_pPlayButton->setPressedImage(pManager->getDriver()->getTexture("media/buttons/but_play_on.bmp"));
// add other button
.....
}
Code: Select all
pManager->getDevice()->getCursorControl()->setVisible(true),
where is wrong?
i breakpoint at
Code: Select all
CGameMenuState::OnEvent or CGameManager.
s32 id = event.GUIEvent.Caller->getID();