How to create an infinite background in cocos2d without block Gap.I am building an app with a ball moving from left to right, and I want it to move infinitely. Well in that case I would have an endless background so the ball could keep moving.I got gab between the image .I've continuously searched on this matter and have found nothing that actually works.
I have added code below
-(void)scroll:(ccTime )time
{
tree1.position = ccp(tree1.position.x-1, tree1.position.y);
tree2.position = ccp(tree2.position.x-1, tree2.position.y);
if (tree1.position.x<-tree1.boundingBox.size.width) {
tree1.position = ccp(tree2.position.x +tree2.boundingBox.size.width, tree1.position.y);
}
if (tree2.position.x<-tree2.boundingBox.size.width) {
tree2.position = ccp(tree1.position.x + tree2.boundingBox.size.width, tree1.position.y);
}
}