Hey!
I'm going absolutely insane here. I made a simple infinitely scrolling background using two images.
The problem is after a while the images seem to slowly split apart and show a 2-3 pixel gap. I don't understand how to fix this. I saw a video tutorial and copied the guys code and it still did it but his in the video did not.
Here is my code WTF?
the image is a full screen size, 480x320
bg1 = [CCSprite spriteWithFile:@"trackbg.png"];
bg1.anchorPoint = ccp(0,0);
bg1.position = ccp(0,0);
[self addChild:bg1];
bg2 = [CCSprite spriteWithFile:@"trackbg.png"];
bg2.anchorPoint = ccp(0,0);
bg2.position = ccp(479,0);
[self addChild:bg2];
[self schedule:@selector(updatedSpeed:) interval: .02 ];
}
return self;
}
-(void) updatedSpeed:(ccTime)dt {
bg1.position = ccp( bg1.position.x - 2 , 0 );
bg2.position = ccp( bg2.position.x - 2 , 0 );
if (bg1.position.x == -bg1.contentSize.width) {
bg1.position = ccp(479,0);
}
if (bg2.position.x == -bg2.contentSize.width) {
bg2.position = ccp(479,0);
}
}
I'm using 479 because if I use 480 there will be a gap I tried making them overlap more by using 475 but it still creating the gap.