Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7409423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:04:52+00:00 2026-05-29T06:04:52+00:00

I am trying to get the swiping to work for Cocos2d latest version here

  • 0

I am trying to get the swiping to work for Cocos2d latest version here is my code:

-(void) setupGestureRecognizers 
{
    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeft)];

    [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];

    [swipeLeft setNumberOfTouchesRequired:1];

    [[[CCDirector sharedDirector] openGLView] addGestureRecognizer:swipeLeft];


}

It does not detect the swipe at all!

UPDATE 1:

I updated the code to the following and still no swipes are detected.

-(void) setupGestureRecognizers 
{
    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeft)];

    [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];

    [swipeLeft setNumberOfTouchesRequired:1];

    [[[[CCDirector sharedDirector] openGLView] window] setUserInteractionEnabled:YES];

    [[[CCDirector sharedDirector] openGLView] setUserInteractionEnabled:YES];
    [[[CCDirector sharedDirector] openGLView] addGestureRecognizer:swipeLeft];


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:04:52+00:00Added an answer on May 29, 2026 at 6:04 am

    I’ve tried to make this work as well but I’ve found an easier and also better to control method.

    so for example if you wanted to detect a swipe to the left I’d so following.

    Declare two variables in the interface of you’re class

    CGPoint firstTouch;
    CGPoint lastTouch;
    

    In the init method of the implementation of your class enable touches

    self.isTouchEnabled = YES;
    

    3.Add these methods to your class

    -(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        NSSet *allTouches = [event allTouches];
        UITouch * touch = [[allTouches allObjects] objectAtIndex:0];
        CGPoint location = [touch locationInView: [touch view]];
        location = [[CCDirector sharedDirector] convertToGL:location];
    
        //Swipe Detection Part 1
        firstTouch = location;
    }
    
    -(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        NSSet *allTouches = [event allTouches];
        UITouch * touch = [[allTouches allObjects] objectAtIndex:0];
        CGPoint location = [touch locationInView: [touch view]];
        location = [[CCDirector sharedDirector] convertToGL:location];
    
        //Swipe Detection Part 2
        lastTouch = location;
    
        //Minimum length of the swipe
        float swipeLength = ccpDistance(firstTouch, lastTouch);
    
        //Check if the swipe is a left swipe and long enough
        if (firstTouch.x > lastTouch.x && swipeLength > 60) {
            [self doStuff];
        }
    
    }
    

    the method “doStuff” is whats called if a left swipe has occurred.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
I am trying to get the word after Sysdba. out of a string. Here
When I'm trying get method from remote webservice it gives me error. My code
I'm trying get LocalConnection to work between two swf's placed within two different IFRAMES.
I'm trying get some licensing code from AndroidPit.com working, but I get Unable to
I am trying get Javascript popup calendar control to work which doesnt work. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.