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 6922101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:21:47+00:00 2026-05-27T10:21:47+00:00

I have a sprite on which there is a label (CCLabelTTF). On that label

  • 0

I have a sprite on which there is a label (CCLabelTTF). On that label i have A,B,C,D,E, etc printed when they are clicked. I want them to scroll left. I’ve googled some tuorials but i am unable to find the solution and stuck here for long. Here is the screenshot of my game. You can see the characters from A to J. When i click on more incoming characters, that portion should scroll. What can i do to make the characters scroll?

Here is the code from which the characters are shown on label (lblSelectedAlpha) added on sprite:-

-(void)showSelectedAlphaBet{

    fSelectedAlphaY =26;     
    if (tempBackground) {       
        [tempBackground removeFromParentAndCleanup:YES];
    }   
    tempBackground = [CCSprite spriteWithFile:@"stripe_2.png"];
    tempBackground.position = ccp(160,30);
    [self addChild:tempBackground z:30];        
    for (int i=0; i<[arryAddSelectedChar count]; i++) {     
       // NSLog(@"[arryAddSelectedChar count] %@",[arryAddSelectedChar objectAtIndex:i]);       
        lblSelectedAlpha = [CCLabelTTF labelWithString:
                        [arryAddSelectedChar objectAtIndex:i]dimensions:CGSizeMake(30,30)
                                         alignment:UITextAlignmentCenter  fontName:@"Marker Felt" fontSize:30];     
        lblSelectedAlpha.position = ccp(fSelectedAlphaY,25);
        lblSelectedAlpha.tag=i;
        lblSelectedAlpha.color = ccc3(125,125,125);
        [tempBackground addChild:lblSelectedAlpha z:5];     
        fSelectedAlphaY +=25;     
    }
}
  • 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-27T10:21:47+00:00Added an answer on May 27, 2026 at 10:21 am

    Well, this is how i implemented scrolling in my cocos2d game

    // How to add scroll on label. This i did with a UITextView

    // inside init, i took

    {

        scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(10,430, 150, 50)]
        alphabetScroll = [[UITextView alloc] initWithFrame:CGRectMake(10,0,50 ,50)];
        alphabetScroll.font = [UIFont fontWithName:@"verdana" size:30.0f];
        alphabetScroll.backgroundColor = [UIColor clearColor];
        alphabetScroll.textColor = [UIColor colorWithRed:125.0/255.0 green:125.0/255.0 blue:125.0/255.0 alpha:1.0f];
        alphabetScroll.userInteractionEnabled=NO;
    
        [scroll addSubview:alphabetScroll];
        [[[CCDirector sharedDirector]openGLView]addSubview:scroll]; 
    

    }

    -(void)showSelectedAlphaBet

    {

    NSLog(@"showSelectedAlphaBet");
    
    fSelectedAlphaY =26;   // I have 26 alphabets
    
    if (tempBackground) {
    
        [tempBackground removeFromParentAndCleanup:YES];
    }
    

    // Area where alphabets are added on touch

    tempBackground = [CCSprite spriteWithFile:@"stripe_2.png"];
    tempBackground.position = ccp(160,30);
    [self addChild:tempBackground z:30];
    bottomAlphabet = @" ";
    
    for (int i=0; i<[arryAddSelectedChar count]; i++) {
    
        NSLog(@"[arryAddSelectedChar count] %@",[arryAddSelectedChar objectAtIndex:i]);
    
        bottomAlphabet = [bottomAlphabet stringByAppendingString:[arryAddSelectedChar objectAtIndex:i]];
    }
    

    // Implementing shifting/scrolling

    int newScrollViewWidth;
    int newLabelWidth;
    newScrollViewWidth =25*[arryAddSelectedChar count];
    newLabelWidth =50*[arryAddSelectedChar count];
    
    [scroll setContentSize:CGSizeMake(newScrollViewWidth, 45)];
    
    alphabetScroll.frame =  CGRectMake(0, 0, newLabelWidth, 45);
    
    alphabetScroll.text = bottomAlphabet;
    if (newScrollViewWidth > 150) {
        CGPoint svos;
        CGPoint pt;
        svos = scroll.contentOffset;
        CGRect rc = [alphabetScroll bounds];
        rc = [alphabetScroll convertRect:rc toView:scroll];
        pt = rc.origin;
        pt.y = 0;
        pt.x += 20*([arryAddSelectedChar count]-5);
    
        [scroll setContentOffset:pt animated:YES];       
    }
    

    }

    // In dealloc

    [alphabetScroll release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a sprite, with which I have drawn some stuff, how do
I have written a CSS sprite auto-generator which takes selected images out of the
I have a sprite loaded from a PNG that has an alpha channel. The
I have a Flash sprite in my Director project. Under the Properties of that
I have a sprite sheet which has each image centered in a 32x32 cell.
I have a class which makes a url request and stores data from that
One thing I have noticed on some sites is that they use one BIIIIIIIG
I have a Sprite which is a child of a Flex object, and acts
I have a class called Projectiles which inherits from CCSprite class, Currently there are
I have a control (picturebox), in which I want to draw an 2D image

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.