I'm working on an iPhone app and in my app there's an object that moves from the top to the bottom of the screen. To do this I use a CADisplay link. Once the object leaves the screen it is supposed to restart its route. The problem that I'm encountering is that each time the object restarts its route, it speeds up. This continues until the object is going so fast that you can barely see it. Any ideas why this is happening and how to stop it? Any help is appreciated, thanks in advance!
-(void)spawnButton{
int x = (arc4random() % (240) + 40;
int y = -100;
button1.center = CGPointMake(x,y);
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(moveObject)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
}
-(void) moveObject {
int z = 1;
button1.center = CGPointMake(button1.center.x , button1.center.y +z);
if (button1.center.y >= 480) {
[self spawnButton];
}
}