NSTimer vs CACurrentMediaTime()

前端 未结 2 693
庸人自扰
庸人自扰 2020-12-24 07:33

So I\'m amidst my first iOS game and am struggling with how to go about the best way to integrate object movement.

The game relies heavily on fast moving objects an

2条回答
  •  有刺的猬
    2020-12-24 07:43

    According to the NSTimer documentation the effective resolution of the time interval for a timer is limited to on the order of 50-100 milliseconds. which is probably why your seeing a variation in the time interval.

    What I would suggest doing is change your update interval to 0.016 sec since there is no reason for your game state to update more often than the screen can draw it. Then you can use a CADisplayLink to handle the timing. This should be very accurate since its using the displays refresh rate.

提交回复
热议问题