Question

For example in cocos2D:

- (void)update:(ccTime)delta

can someone explain what these time deltas or timestamps are used for? How are they relevant for how the game world is updated? Is it because we do not know the fps reliably and should not just rely on incremental property updates based on -update calls?

Was it helpful?

Solution

It is important for making frame independent movement. Typically any character movement you take into consideration the time since the last update call.

This is to ensure that your game behaves the same across devices of various performance. If you move a character by 1 pixel every frame then on a device that runs at 60fps the character will move twice as fast as on a device that gets 30fps.

By affecting all movement code for example by the delta time you ensure that all devices will behave the same.

It is simple to make movement frame rate independent. Something like multiplying a movement vector by deltaTime will achieve this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top