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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:14:09+00:00 2026-06-09T22:14:09+00:00

i have 3 images and i would like to repeat them, one after the

  • 0

i have 3 images and i would like to repeat them, one after the other. When the layer has moved to the left, the first image is not visible anymore and this image takes its new position just after the last image to the right, so that the first image becomes the third one, and the animation is repeated.

My problem is, there is a little time lapse sometimes, i think it happens when the first image is removed and put to the third position. We barely notice it, but it is sort of “pausing” the animation for 0.1 sec and i would like to avoid this.

Would you know how? I have tried with this code (remove the image and insert it again), or just by replacing with replace...atIndex but i have got the same problem. The code is :

if (offsetParam <= offset1-spriteWidth){
        CCSprite *temp = [[sprites objectAtIndex:0] retain];
        [sprites removeObjectAtIndex:0];
        [sprites addObject:temp];
        temp.position = ccp(-offset1+(2*spriteWidth), temp.position.y);
        [temp release];

        offset1 -= spriteWidth;
 }

Any idea ?

Thanks


EDIT:
with a counter, the object does not move?
(i have tried with a “retain” just in case, but with or without it, i have got the same result)

if (rightDirection){
    //RIGHT
    CCLOG(@"offsetParam %f, offset1-spriteWidth %f", offsetParam, offset1-spriteWidth);
    if (offsetParam < offset1-spriteWidth){ //move the block to the right

        CCSprite *temp = [[grasses objectAtIndex:counterGrass] retain];
        counterGrass++;
        if (counterGrass>2) counterGrass = 0;
        temp.position = ccp(offset1+(2*spriteWidth), temp.position.y);//does not work
        [temp release];
        offset1 -= spriteWidth;
    }
  • 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-06-09T22:14:11+00:00Added an answer on June 9, 2026 at 10:14 pm

    Is “sprites” of type CCArray or NSMutableArray? Because CCArray has a serious performance issue with removeObjectAtIndex, particularly if the index is low (at the beginning of the array) as in your case.

    You could try switching to NSMutableArray and see if that helps.

    Alternatively, avoid using remove and add because it’s superfluous. Instead use an index counter that tells you which array index is the first sprite. When the index is >= the number of items in the sprites array, reset it to 0.

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

Sidebar

Related Questions

So in my project i would like have a nice treeview that has images.
I have two images which i would like to compare and do different operations
I have images in divs and I would like to have paragraphs to appear
I have large images displayed in a grouped tableview. I would like the images
I have several images stored in content://media/external/images/media. I would like to display by using
I have a directory full of images that I would like to resize to
I would like to have formatted, clickable text and images inside a selected UITableViewCell.
I would like to have our web applications pull static content (css, js, images)
I have a div which contains a number of images. I would like to
I have an image in WPF that I would like to have display different

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.