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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:36:40+00:00 2026-05-22T16:36:40+00:00

Hi i m new to iphone.. Now i am trying to continuous scroll my

  • 0

Hi i m new to iphone.. Now i am trying to continuous scroll my background. I have added an image as a child . Now the code i m using for continuous scrolling is this on

[bg1 setPosition:ccp(310, 160)];
CCSprite *bg2 = [CCSprite spriteWithFile:@"lines.jpg"];
[bg2 setPosition:ccp(880, 160)];
id enterRight = [CCMoveTo actionWithDuration:4 position:ccp(310, 160)];
id exitLeft = [CCMoveTo actionWithDuration:4 position:ccp(-310, 160)];
id reset = [CCMoveTo actionWithDuration:0 position:ccp(880, 160)];
id enterRight2 = [CCMoveTo actionWithDuration:4 position:ccp(310, 160)];
id exitLeft2 = [CCMoveTo actionWithDuration:4 position:ccp(-310, 160)];
id reset2 = [CCMoveTo actionWithDuration:0 position:ccp(880, 160)];
id seq1 = [CCSequence actions: exitLeft, reset, enterRight, nil];
id seq2 = [CCSequence actions: enterRight2, exitLeft2, reset2, nil];
[bg1 runAction:[CCRepeatForever actionWithAction:seq1]];
[bg2 runAction:[CCRepeatForever actionWithAction:seq2]];
[self addChild:bg1 z:-1 tag:1234];
[self addChild:bg2 z:-1 tag:2345];

The Problem I m getting is this that the image is scrolling continuously alright but when the enter the screen they are adjacent to each other but as they scroll towards the other side of the screen there comes a gap between the two images and it tends to widen as the image scrolls.. Any idea or suggestion why is this happening ?
another thing someone said we could use update for background scrolling. Looks something like this.

[self schedule: @selector(update:)];


- (void) update: (ccTime) dt
{
    float dy = scroll_speed_per_second * dt;
    [self setPosition:ccp(self.position.x,self.position.y + dy)];
}

Just one more thing i wanna ask.. i am able to scroll the images using upper method too but i m unable to reset the image back to there position. Do i have to reset the child back to its position or the whole frame. Any help will be appreciated. Thanks.

  • 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-22T16:36:41+00:00Added an answer on May 22, 2026 at 4:36 pm

    heye Nick,

    i dont seem to fully understand your code and it doesnt seem to be a good practice too..
    what you can do is use CCPlace.

    Simply move your sprite till the target position and then use ccplace to reset your sprites position.

    Like this…

    cloud1=[Obstacle spriteWithFile:@"IT_Cloud1.png" type:CLOUD1];
    [self addChild:cloud1 z:4];
    cloud1.position=ccp(500,270);
    id rptFrvr1=[CCRepeatForever actionWithAction:[CCSequence actions:
                                            [CCMoveTo actionWithDuration:7 position:ccp(-100,270)],
                                                  [CCPlace actionWithPosition:ccp(500,270)],nil]];
    [cloud1 runAction:rptFrvr1];
    
    
    
    cloud2=[Obstacle spriteWithFile:@"IT_Cloud2.png" type:CLOUD2];
    [self addChild:cloud2 z:1];
    cloud2.position=ccp(700,280);
    id rptFrvr2=[CCRepeatForever actionWithAction:[CCSequence actions:
                                                  [CCMoveTo actionWithDuration:12 position:ccp(-200,280)],
                                                  [CCPlace actionWithPosition:ccp(700,280)],nil]];
    [cloud2 runAction:rptFrvr2];
    

    dont get confused by “type” parameter …dat is just my own implementation of ccsprite..u can simply use ccSprite spritewithfile:

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

Sidebar

Related Questions

i'm new at IPhone SDK Developing and now i need some help. I have
friends I am new to iphone development, I have mostly worked with Android, now
I signed up for the iPhone Developer Program (now awaiting approval) using a new
I am new to iPhone development. I have created the database using the terminal
I am fairly new to iPhone development. Right now, I am working on an
First off I am very new to Objective C and iPhone programming. Now that
I have a new iPhone app that has the following (and only the following)
I've just set up a new computer and now trying to install my app
I'm new to iPhone programming and I'm trying to use CHDataStructures in my project.
I'm new to iPhone programming, so I might not even be using the correct

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.