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

  • Home
  • SEARCH
  • 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 6807971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:53:52+00:00 2026-05-26T19:53:52+00:00

I have a CCScene. In its right side I need to have a UIScrollView

  • 0

I have a CCScene. In its right side I need to have a UIScrollView with some menu elements. I did it this way as I have explained in this previous question Cocos2d and UIScrollView

here is the method creating my scene

  +(id) scene: (int) wld{
    CCScene *scene = [CCScene node];
    LevelsMenu *layer = [LevelsMenu node];
    layer = [layer init:wld];
    [scene addChild: layer];
    [layer setScrollView:[LevelMenuControlView alloc]];
    [[[CCDirector sharedDirector] openGLView] addSubview:layer.scrollView.view];
    return scene;
 }

notice that LevelMenuControlView is just an UIViewController implemented this way:

 - (void)loadView{
 LevelMenuView *scrollView = [[LevelMenuView alloc] initWithFrame:[UIScreen 
    mainScreen].applicationFrame];

scrollView.contentSize = CGSizeMake(862, 480);

scrollView.delegate = scrollView;
[scrollView setUserInteractionEnabled:TRUE];
[scrollView setScrollEnabled:TRUE];
[scrollView setShowsVerticalScrollIndicator:FALSE];
[scrollView setShowsHorizontalScrollIndicator:FALSE];
self.view = scrollView;

[scrollView release];
 }

While LevelMenuView is the UIScrollView containing the menu elements

It works quite fine. Now the problem is that in the left side of the scene I have a sprite animation that, If I do not touch the screen fine but as soon as I drag the scroll view up or down stops or goes at the same speed of my scrolling finger!!!

Any idea?

  • 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-26T19:53:53+00:00Added an answer on May 26, 2026 at 7:53 pm

    I have found this link where someone already experienced the same problem and posted a solution which actually works

    http://www.cocos2d-iphone.org/forum/topic/11645

    It basically consists in adding this code to the scroll view:

    // This should go in your interface.
     NSTimer *timer;
    
    // Override
    - (void)setContentOffset:(CGPoint)contentOffset {
    // UIScrollView uses UITrackingRunLoopMode.
    // NSLog([[NSRunLoop currentRunLoop] currentMode]);
    
    // If we're dragging, mainLoop is going to freeze.
    if (self.dragging && !self.decelerating) {
    
    // Make sure we haven't already created our timer.
    if (timer == nil) {
    
     // Schedule a new UITrackingRunLoopModes timer, to fill in for    
     CCDirector while we drag.
            timer = [NSTimer scheduledTimerWithTimeInterval:[[CCDirector sharedDirector] animationInterval] target:self selector:@selector(animateWhileDragging) userInfo:nil repeats:YES];
    
                        // This could also be NSRunLoopCommonModes
            [[NSRunLoop currentRunLoop] addTimer:timer forMode:UITrackingRunLoopModes];
        }
    }
    
    // If we're decelerating, mainLoop is going to stutter.
    if (self.decelerating && !self.dragging) {
    
        // Make sure we haven't already created our timer.
        if (timer == nil) {
    
            // Schedule a new UITrackingRunLoopMode timer, to fill in for CCDirector while we decellerate.
            timer = [NSTimer scheduledTimerWithTimeInterval:[[CCDirector sharedDirector] animationInterval] target:self selector:@selector(animateWhileDecellerating) userInfo:nil repeats:YES];
            [[NSRunLoop currentRunLoop] addTimer:timer forMode:UITrackingRunLoopMode];
        }
    }
    
    [super setContentOffset:contentOffset];
    }
    - (void)animateWhileDragging {
    
    // Draw.
    [[CCDirector sharedDirector] drawScene];
    
    if (!self.dragging) {
    
        // Don't need this timer anymore.
        [timer invalidate];
        timer = nil;
    }
    }
    - (void)animateWhileDecellerating {
    
    // Draw.
    [[CCDirector sharedDirector] drawScene];
    
    if (!self.decelerating) {
    
        // Don't need this timer anymore.
        [timer invalidate];
        timer = nil;
    }
    }
    

    Thanks a lot to these guys

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

Sidebar

Related Questions

I have this main scene in a game and I have called the menu
Have some dates in my local Oracle 11g database that are in this format:
so I have this: CCLabelBMFont *timeLabel = [[CCLabelBMFont alloc] initWithString:@abc fntFile:@clean_3.fnt]; in a CCScene
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have converted devise new session from erb to Haml but doens't work, this is
I have a scene created like that: MyScene (subclass of CClayer) .m +(CCScene *)
ok i am new to coding and cocos2d i have this shooting code that
I am newbie to Cocos2d. I have this layer that represents my main game
Have written all the code in a silverlight class library (dll) and linked this
I have an sprite the I need to rotate it with touch but it

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.