I'm trying to have a background loop that has constantly scrolling clouds, but no matter what I try I seem to have a line inbetween the tiles as they wrap around. The full code is below. Any suggestions on how to improve it are very welcome, especially regarding the lines/creases between sprites.
@implementation Sky
@synthesize vx;
@synthesize vy;
- (id) init {
self = [super init];
if (self != nil) {
Sprite *cloud1 = [Sprite spriteWithFile:@"sky.png"];
[cloud1 setPosition: ccp(0, 290)];
[self addChild: cloud1];
Sprite *cloud2 = [Sprite spriteWithFile:@"sky.png"];
[cloud2 setPosition: ccp(500, 290)];
[self addChild: cloud2];
[self schedule: @selector(update:)];
}
return self;
}
- (void)update:(ccTime)dt {
NSArray* _children = [self children];
for(Sprite* child in _children) {
float x = child.position.x + 1.0f;
if (x > 750) {
x = -250;
}
child.position = ccp(x, 290.0f);
}
}
@end