FlxVelocity
offers several helper functions to move objects towards the mouse, a certain point, a touch, or another object.
Use moveTowardsMouse
, moveTowardsPoint
, moveTowardsTouch
, and moveTowardsObject
if you need a simple way to move an object around.
// move `target` towards the mouse at `speed` pixels per second
FlxVelocity.moveTowardsMouse(target, speed);
< Note: There are similar `accelerateTowards*` functions that can be used as well.