Advanced TimeDelta

Post your own tutorials, guides and demos.

Post » Thu Oct 16, 2008 2:22 pm

Quick example showing how you can achieve non-linear movement which is constant at any framerate.

The sprite chases the mouse cursor by closing in a certain percentage of the distance remaining every tick. Since it uses TimeDelta, it works the same rate at all framerates. Try it - fixed 10fps or unlimited, even with a hundreds of times higher framerate it still goes at the same rate.

Just thought I'd share it, because the formula is a bit tricky to work out otherwise ;) Also a good example of interesting places to use lerp().
Scirra Founder
Posts: 22,829
Reputation: 176,674

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 3 guests