Skip to content

poowww/EventListenerGesture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 

Repository files navigation

EventListenerGesture

cocos2d-x3 EventListener for Gesture(Tap, LongTap, Swipe).

Example

auto listener = EventListenerGesture::create();

//if dont set this value is 0.1f.
listener->setLongTapThreshouldSeconds(1.0f);
//if dont set this value is 10.0f.
listener->setSwipeThreshouldDistance(150.0f);
listener->onTap = [](Vec2 vec2){log("onTap called.");};
listener->onLongTapBegan = [](Vec2 vec2){log("onLongTapBegan called.");};
listener->onLongTapEnded = [](Vec2 vec2){log("onLongTapEnded called.");};
listener->onSwipe = [](EventListenerGesture::SwipeDirection direction)
{
   switch (direction) {
       case EventListenerGesture::SwipeDirection::UP:
           log("Swipe UP.");
           break;
       case EventListenerGesture::SwipeDirection::DOWN:
           log("Swipe DOWN.");
           break;
       case EventListenerGesture::SwipeDirection::RIGHT:
           log("Swipe RIGHT.");
           break;
       case EventListenerGesture::SwipeDirection::LEFT:
           log("Swipe LEFT.");
           break;
       default:
           break;
   }
};

getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);

About

Cocos2d-x EventListener for Gesture(Tap, LongTap, Swipe).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages