###

» Sun Dec 15, 2013 5:02 am

Lerp isn't actually for easing, it's for getting a position between two points. But I get what you're saying and my guess is you're using keep in an event like this.

Every tick

---Sprite: set x to lerp(self.x, 100, 0.5)

Which gives the effect of moving fast to slow. What it's doing is just moving half the distance per frame.

You'll need to add a variable for a reverse effect.

To start it set the variable to say o.

Set speed to 0

Then every tick set a new x and increase the speed

Every tick

--- set x to min(self.x + speed, 100)

--- add 1 to speed

The min() is to keep from overshooting. Also note this only works for a positive direction. For a negative direction do this:

Every tick

--- set x to max(self.x - speed, -100)

--- subtract 1 from speed

Also you can fix it up to use dt so it behaves the same regardless of the framerate. R0J0hound2013-12-15 05:05:37