Static methods

@:value({ resetVelocity : true })staticinlineaccelerateFromAngle(source:FlxSprite, radians:Float, acceleration:Float, maxSpeed:Float, resetVelocity:Bool = true):Void

Sets the x/y acceleration on the source FlxSprite so it will accelerate in the direction of the specified angle. You must give a maximum speed value (in pixels per second), beyond which the FlxSprite won't go any faster.

Parameters:

Source

The FlxSprite on which the acceleration will be set

Radians

The angle in which the FlxPoint will be set to accelerate

Acceleration

The speed it will accelerate in pixels per second

MaxSpeed

The maximum speed in pixels per second in which the sprite can move

ResetVelocity

Whether to reset the FlxSprite velocity to 0 each time

staticaccelerateTowardsMouse(Source:FlxSprite, Acceleration:Float, MaxSpeed:Float):Void

Sets the x/y acceleration on the source FlxSprite so it will move towards the mouse coordinates at the speed given (in pixels per second) You must give a maximum speed value, beyond which the FlxSprite won't go any faster. If you don't need acceleration look at moveTowardsMouse() instead.

Parameters:

Source

The FlxSprite on which the acceleration will be set

Acceleration

The speed it will accelerate in pixels per second

MaxSpeed

The maximum speed in pixels per second in which the sprite can move

staticaccelerateTowardsObject(Source:FlxSprite, Dest:FlxSprite, Acceleration:Float, MaxSpeed:Float):Void

Sets the x/y acceleration on the source FlxSprite so it will move towards the destination FlxSprite at the speed given (in pixels per second) You must give a maximum speed value, beyond which the FlxSprite won't go any faster. If you don't need acceleration look at moveTowardsObject() instead.

Parameters:

Source

The FlxSprite on which the acceleration will be set

Dest

The FlxSprite where the source object will move towards

Acceleration

The speed it will accelerate in pixels per second

MaxSpeed

The maximum speed in pixels per second in which the sprite can move

staticaccelerateTowardsPoint(Source:FlxSprite, Target:FlxPoint, Acceleration:Float, MaxSpeed:Float):Void

Sets the x/y acceleration on the source FlxSprite so it will move towards the target coordinates at the speed given (in pixels per second) You must give a maximum speed value, beyond which the FlxSprite won't go any faster. If you don't need acceleration look at moveTowardsPoint() instead.

Parameters:

Source

The FlxSprite on which the acceleration will be set

Target

The FlxPoint coordinates to move the source FlxSprite towards

Acceleration

The speed it will accelerate in pixels per second

MaxSpeed

The maximum speed in pixels per second in which the sprite can move

staticaccelerateTowardsTouch(Source:FlxSprite, Touch:FlxTouch, Acceleration:Float, MaxSpeed:Float):Void

Sets the x/y acceleration on the source FlxSprite so it will move towards a FlxTouch at the speed given (in pixels per second) You must give a maximum speed value, beyond which the FlxSprite won't go any faster. If you don't need acceleration look at moveTowardsMouse() instead.

Parameters:

Source

The FlxSprite on which the acceleration will be set

Touch

The FlxTouch on which to accelerate towards

Acceleration

The speed it will accelerate in pixels per second

MaxSpeed

The maximum speed in pixels per second in which the sprite can move

staticcomputeVelocity(Velocity:Float, Acceleration:Float, Drag:Float, Max:Float, Elapsed:Float):Float

A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.

Parameters:

Velocity

Any component of velocity (e.g. 20).

Acceleration

Rate at which the velocity is changing.

Drag

Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.

Max

An absolute value cap for the velocity (0 for no cap).

Elapsed

The amount of time passed in to the latest update cycle

Returns:

The altered Velocity value.

@:value({ MaxTime : 0, Speed : 60 })staticmoveTowardsMouse(Source:FlxSprite, Speed:Float = 60, MaxTime:Int = 0):Void

Move the given FlxSprite towards the mouse pointer coordinates at a steady velocity If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms. The source object doesn't stop moving automatically should it ever reach the destination coordinates.

Parameters:

Source

The FlxSprite to move

Speed

The speed it will move, in pixels per second (default is 60 pixels/sec)

MaxTime

Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms

@:value({ MaxTime : 0, Speed : 60 })staticmoveTowardsObject(Source:FlxSprite, Dest:FlxSprite, Speed:Float = 60, MaxTime:Int = 0):Void

Sets the source FlxSprite x/y velocity so it will move directly towards the destination FlxSprite at the speed given (in pixels per second) If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms. The source object doesn't stop moving automatically should it ever reach the destination coordinates. If you need the object to accelerate, see accelerateTowardsObject() instead Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all)

Parameters:

Source

The FlxSprite on which the velocity will be set

Dest

The FlxSprite where the source object will move to

Speed

The speed it will move, in pixels per second (default is 60 pixels/sec)

MaxTime

Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms

@:value({ MaxTime : 0, Speed : 60 })staticmoveTowardsPoint(Source:FlxSprite, Target:FlxPoint, Speed:Float = 60, MaxTime:Int = 0):Void

Sets the x/y velocity on the source FlxSprite so it will move towards the target coordinates at the speed given (in pixels per second) If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms. The source object doesn't stop moving automatically should it ever reach the destination coordinates.

Parameters:

Source

The FlxSprite to move

Target

The FlxPoint coordinates to move the source FlxSprite towards

Speed

The speed it will move, in pixels per second (default is 60 pixels/sec)

MaxTime

Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms

@:value({ MaxTime : 0, Speed : 60 })staticmoveTowardsTouch(Source:FlxSprite, Touch:FlxTouch, Speed:Float = 60, MaxTime:Int = 0):Void

Move the given FlxSprite towards a FlxTouch point at a steady velocity If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms. The source object doesn't stop moving automatically should it ever reach the destination coordinates.

Parameters:

source

The FlxSprite to move

speed

The speed it will move, in pixels per second (default is 60 pixels/sec)

maxTime

Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms

staticinlinevelocityFromAngle(Angle:Float, Speed:Float):FlxPoint

Given the angle and speed calculate the velocity and return it as an FlxPoint

Parameters:

Angle

The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)

Speed

The speed it will move, in pixels per second sq

Returns:

A FlxPoint where FlxPoint.x contains the velocity x value and FlxPoint.y contains the velocity y value

staticvelocityFromFacing(Parent:FlxSprite, Speed:Float):FlxPoint

Given the FlxSprite and speed calculate the velocity and return it as an FlxPoint based on the direction the sprite is facing

Parameters:

Parent

The FlxSprite to get the facing value from

Speed

The speed it will move, in pixels per second

Returns:

An FlxPoint where FlxPoint.x contains the velocity x value and FlxPoint.y contains the velocity y value