0

My Sprite jumps on the screen and looks laggy. I was wondering on how to make the movement smoother and not as laggy. The code I use for movement is below.

birdMovement = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(birdMoving) userInfo:nil repeats:YES];
TunnelMovement = [NSTimer scheduledTimerWithTimeInterval:0.08 target:self selector:@selector(tunnelMoving) userInfo:nil repeats:YES];
Popeye
  • 11,839
  • 9
  • 58
  • 91

2 Answers2

0

You should use SKAction class instead of NSTimer.

AndrewShmig
  • 4,843
  • 6
  • 39
  • 68
  • would i just implement it the same way as i did with NSTimer? – user2464778 Mar 30 '14 at 13:46
  • @user2464778, something like this: [SKAction moveTo:CGMakePoint(100, 100) duration:2.0]. After creating an SKAction you can run this action on your sprite node like this: [node runAction:action] – AndrewShmig Mar 30 '14 at 17:55
0

If you're writing your first game you should be using SpriteKit. It handles a lot of stuff like this for you. Be sure to read the documentation completely before beginning so you get an understanding of how it all works.

nsdebug
  • 364
  • 2
  • 8
  • So would it not be possible to implement SKAction anymore, because instead of View it would have to be a Scene. Is there still a way of making the movement smooth? – user2464778 Mar 30 '14 at 14:00
  • Your best bet is to look into CADisplayLink if you don't want to use SpriteKit. https://developer.apple.com/library/ios/documentation/QuartzCore/Reference/CADisplayLink_ClassRef/Reference/Reference.html – nsdebug Mar 30 '14 at 14:02