当前位置: 首页>>代码示例>>C++>>正文


C++ KeyEvent::GetKeyEventType方法代码示例

本文整理汇总了C++中KeyEvent::GetKeyEventType方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::GetKeyEventType方法的具体用法?C++ KeyEvent::GetKeyEventType怎么用?C++ KeyEvent::GetKeyEventType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyEvent的用法示例。


在下文中一共展示了KeyEvent::GetKeyEventType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleEvent

 void SubSectionMenu::HandleEvent(Event* aEvent)
 {
     switch(aEvent->GetEventCode())
     {
         case BUTTON_ACTION:
         {
             //If the scene isn't active, then we want to ignore all button action events
             if(ServiceLocator::GetSceneManager()->IsActiveScene(this) == false)
             {
                 return;
             }
         
             //Get the button pointer from the event data
             Button* button = (Button*)aEvent->GetEventData();
         
             int index = -1;
         
             //Determine the index of the button that was pressed
             const unsigned int buttonCount = WORLD_NUMBER_OF_SUBSECTIONS.x * WORLD_NUMBER_OF_SUBSECTIONS.y;
             for(unsigned int i = 0; i < buttonCount; i++)
             {
                 if(button == m_Buttons[i])
                 {
                     index = i;
                     break;
                 }
             }
             
             //Safety check the index
             if(index != -1)
             {
                 //Check the coordinates for the
                 uvec2 coordinates = uvec2(0,0);
                 coordinates.x = (index % WORLD_NUMBER_OF_SUBSECTIONS.x);
                 coordinates.y = ((index - coordinates.x) / WORLD_NUMBER_OF_SUBSECTIONS.x);
             
                 //Set the filename, based on the button's coordinates
                 stringstream ss;
                 ss << "SubSection" << coordinates.x << "-" << coordinates.y << ".bin";
             
                 //Are we saving OR loading?
                 if(m_SaveSubSection != nullptr)
                 {
                     m_SaveSubSection->Save(ss.str());
                     m_SaveSubSection = nullptr;
                 }
                 else if(m_LoadSubSection != nullptr)
                 {
                     m_LoadSubSection->Load(ss.str());
                     m_LoadSubSection = nullptr;
                 }
                 
                 //We the save OR load operation is done, pop the sub-section menu
                 ServiceLocator::GetSceneManager()->Pop();
             }
         }
         break;
         
         case KEYBOARD_EVENT:
         {
             KeyEvent* keyEvent = (KeyEvent*)aEvent;
             if(keyEvent->GetKeyEventType() == KeyUp)
             {
                 //If the escape key is pressed, pop the sub-section menu
                 if(keyEvent->GetKeyCode() == KEY_CODE_ESCAPE)
                 {
                     ServiceLocator::GetSceneManager()->Pop();
                 }
             }
         }
         break;
     }
 }
开发者ID:Epidilius,项目名称:ZeldaStyleAdventureGame,代码行数:73,代码来源:SubSectionMenu.cpp


注:本文中的KeyEvent::GetKeyEventType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。