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
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests