I have a very simple game loop driven by CADisplayLink. It basically moves a single UIImageView
across screen at a constant rate by updating its position. However, the movement is somewhat jerky.
I'm using the default FrameInterval value of 1 for 60fps. And the image does use transparency.
Just wondering what I can do to improve it. Changing the project to release mode doesn't help.
I tried using a constant delta time of 1/60, and also tried calculating my own delta time,
but that doesn't seem to help either. It doesn't make any difference.
Code:
displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(myGameLoop:)];
[displayLink setFrameInterval:1];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
-(void)myGameLoop {
for(Piece *piece in self.pieces) {
float speed = dt * piece.speed;
piece.center += CGPointMake( dx * speed, dy * speed );
}
}
Any suggestions?