Guest User

Untitled

a guest
May 31st, 2012
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. orxSTATUS orxFASTCALL MenuInputComponent::EventHandler (const orxEVENT *evt)
  2. {
  3.     orxSTATUS result = orxSTATUS_SUCCESS;
  4.  
  5.     if (evt->eType == orxEVENT_TYPE_SYSTEM)
  6.     {
  7.     orxSYSTEM_EVENT_PAYLOAD *payload =
  8.         (orxSYSTEM_EVENT_PAYLOAD *) evt->pstPayload;
  9.     orxVECTOR coords = { payload->stTouch.fX, payload->stTouch.fY, 0 };
  10.  
  11.         if (evt->eID == orxSYSTEM_EVENT_TOUCH_BEGIN)
  12.         {
  13.             //Input::Touch::SetTouchStart (coords);
  14.         }
  15.         else if (evt->eID == orxSYSTEM_EVENT_TOUCH_MOVE)
  16.         {
  17.             Input::Touch::SetTouchMove (coords);
  18.         }
  19.     else if (evt->eID == orxSYSTEM_EVENT_TOUCH_END)
  20.     {
  21.         /*
  22.         const orxVECTOR *touchStart = Input::Touch::GetTouchStart ();
  23.         const orxVECTOR *touchMove  = Input::Touch::GetTouchMove ();
  24.         orxVECTOR moveDistance;
  25.         orxVector_Sub (&moveDistance, touchStart, touchMove);
  26.  
  27.         float swipeThreshold = Input::Touch::GetSwipeThreshold ();
  28.  
  29.         // Finger moved during touch and exceeded swipe gesture threshold?
  30.         if ((touchMove->fX > 0 && touchMove->fY > 0) &&
  31.         (fabs (moveDistance.fX) > swipeThreshold ||
  32.          fabs (moveDistance.fY) > swipeThreshold))
  33.         {
  34.        
  35.         orxSWIPE_EVENT_PAYLOAD payload;
  36.         payload.swipePath = moveDistance;
  37.  
  38.         orxEVENT orxSWIPE_EVENT;
  39.         orxSWIPE_EVENT.eID        = orxSWIPE;
  40.         orxSWIPE_EVENT.eType      = orxEVENT_TYPE_USER_DEFINED;
  41.         orxSWIPE_EVENT.pstPayload = (void *) &payload;
  42.  
  43.         orxEvent_Send (&orxSWIPE_EVENT);
  44.        
  45.         }
  46.         */
  47.     }
  48.     }
  49.     else if (evt->eType == orxEVENT_TYPE_USER_DEFINED)
  50.     {
  51.     if (evt->eID == orxSWIPE)
  52.     {
  53.         orxSWIPE_EVENT_PAYLOAD *payload =
  54.         reinterpret_cast<orxSWIPE_EVENT_PAYLOAD *> (evt->pstPayload);
  55.  
  56.         // Swiped right?
  57.         if (payload->swipePath.fX < 0)
  58.         {
  59.         const char *target = "O-AllLevelIcons";
  60.         orxOBJECT *targetObj = orxObject_GetByName (target);
  61.         orxObject_AddFX (targetObj, "FX-SlideRight");
  62.         }
  63.         // Swiped left?
  64.         else if (payload->swipePath.fX > 0)
  65.         {
  66.         const char *target = "O-AllLevelIcons";
  67.         orxOBJECT *targetObj = orxObject_GetByName (target);
  68.         orxObject_AddFX (targetObj, "FX-SlideLeft");
  69.         }
  70.     }
  71.     }
  72.  
  73.     return result;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment