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: 25,089
Reputation: 199,786

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest