Draknek/FlashPunk — Issue #51: moveTowards moving past target, FP.stepTowards redundancy
Author: medice
Created: 2011-11-14 01:18:04+00:00
State: open

This is annoying:

Entity.moveTowards doesn't check whether amount to move is longer than distance, therefor it sometimes jams moving back and forth, when you expect it to stop at the point we are moving towards.

I found a helper under FP called stepTowards, but the stepTowards does not preserve int values for coordinates and is oddly placed under FP

I edited moveTowards to suit my personal needs but it doesn't take in to account collision during coordinate set in final iteration.

```actionscript
public function moveTowards(x:Number, y:Number, amount:Number, solidType:Object = null, sweep:Boolean = false):void
{
_point.x = x - this.x;
_point.y = y - this.y;
if (_point.length <= amount)
{
this.x = x;
this.y = y;
return;
}
_point.normalize(amount);
moveBy(_point.x, _point.y, solidType, sweep);
}
```