Find file History
Failed to load latest commit information. reorganizing files into recipes folder Mar 7, 2018

id title brief
Time Based Movement in CocosSharp
How to move an object independent of frame rate


Moving game objects should use time when calculating how far to move each frame so that behavior is consistent regardless of frame rate.

Movement can be handled through a Schedule call, which expects an Action<float>. The float parameter is the number of seconds since last frame, so it can be used to perform time based movement. First Schedule must be called:

// assuming this is called in an object that inherits from CCNode, such as an entity:

PerformMovement implements the movement logic as follows:

void PerformMovement(float timeInSeconds)
	float velocity = 10; // in pixels per second
	this.PositionX += velocity * timeInSeconds;