Please bear with me as I've been spending some time lately trying to get a better grasp of some game dev fundamentals. My specific issue is a direct result of trying to apply what I've read about here: When should I use a fixed or variable time step?
I understand that a common option is to write your game framerate-dependent and be done with it. However, once you mix in SKAction
's or physics bodies, this seems like a good way for things to get out of sync. For example, one scenario I can think of is something like an endless runner where the earth is moving beneath you at a steady rate (.position.x -= someDistance
) mixed with other objects whose positions are updated with a [SKAction moveTo: duration:]
, or physics bodies whose positions are updated by applying a force/impulse.
So it makes sense to me that the solution to this problem is to decouple game world updates from frame redraws. This means not using [SKScene update:]
for world updates and instead coming up with your own game loop.
So I guess my question is twofold. Am I on the right track or am I off-base with any of my assumptions? Does Sprite Kit have a game loop set up outside of [SKScene update:]
that is redraw independent, and whose resolution I can specify, that I can leverage? NSTimer
has turned out to be way too inaccurate in my tests. Specifically a practical example would be great.
SKAction
's and physics bodies are updated independently of framerate (as well they should). So I'm trying to better understand where and how to implement such a solution as that option in iOS. Or more specifically, how I would set up such an update loop outside of[SKScene update:]
or am I even grasping the concept correctly? – Manny Oct 28 '14 at 15:27