On 13 Dec 2013, at 10:57 pm, Alex Hall <mehg...@gmail.com> wrote: > To do so smoothly, though, will require a loop, so I can update the position > in small increments many times per second.
You probably know this, but it’s a point worth repeating. Whatever method you use to make the game loop, don’t fall into the trap of assuming that each callback is equivalent to <delta t> seconds. Instead, measure the elapsed time and derive your position(s) accordingly. In other words, suppose you want to move an object from position p1 to position p2 over a period of, say, 1 second. You might assume a framerate of 30fps and therefore divide p2-p1 into thirty equal increments and add that increment at each frame. DO NOT DO THAT! If your timer is held up for any reason, your animation slows down. Instead, calculate the elapsed time at each frame and derive the true position from it. That way, if the timer is held up, your framerate drops but the positions of everything remains correct. Seems obvious but I’ve seen many developers fall into this trap, especially if it’s their first game. —Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com