Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help with continuous scrolling of background on iphone
    text
    copied!<p>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</p> <pre><code>[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]; </code></pre> <p>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.</p> <pre><code>[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)]; } </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload