A collection of extension methods for flixel.math.FlxPoint

Static methods

staticinlinecopy_from_simple (p:FlxPoint, xy:{y:Float, x:Float}):Void

Copy a simple object with x and y floats

Parameters:

p

input

xy

x/y object

staticinlinedistance (p0:FlxPoint, p1:FlxPoint):Float

returns the distance between two points. ex. ship.getMidpoint().distance(target.getMidpoint()) = distance to target

 *  @param p0	first point
 *  @param p1	second point
 *  @return Float

staticinlineget_angle_between (p0:FlxPoint, p1:FlxPoint):Float

returns the angle between two points. ex. ship.getMidpoint().get_angle_between(space_station.getMidpoint()) = heading to space_station

 *  @param p0	first point
 *  @param p1	second point
 *  @return		Float

@:value({ n : 0.5 })staticinlineget_point_between (p0:FlxPoint, p1:FlxPoint, n:Float = 0.5):FlxPoint

returns a point between two points. ex: point1.get_point_between(point2, 0.75) = a point 75% between point1 and point2

 *  @param p0	first point
 *  @param p1	second point
 *  @param n	the norm between the two points (0.5 = half-way)
 *  @return		FlxPoint

staticinlinelimit (p:FlxPoint, min:FlxPoint, max:FlxPoint):FlxPoint

Returns a FlxPoint within limits set by min and max points

Parameters:

p

input

min

minimum limit

max

maximum limit

Returns:

FlxPoint return FlxPoint.get(p.x.min(max.x).max(min.x), p.y.min(max.y).max(min.y))

staticinlineplace_on_circumference (c:FlxPoint, a:Float, r:Float):FlxPoint

returns a point on the circumference of a circle. ex. planet.position.copyFrom(sun.getMidpoint().place_on_circumference(120, dist_from_sun)) = position of planet

 *  @param c	center point
 *  @param a	angle from center
 *  @param r	radius/distance from center
 *  @return		FlxPoint

staticinlineplace_on_tile_anchor (p:FlxPoint, tile_width:Float, ?tile_height:Float):FlxPoint

returns a point at the bottom-center of a tile of a given width and height. ex. pos.place_on_tile_anchor(16) = a point offset from pos by x: 8, and y: 16

 *  @param p			input point
 *  @param tile_width	the width of the tile
 *  @param tile_height	the height of the tile
 *  @return				FlxPoint

staticinlineplace_on_tile_midpoint (p:FlxPoint, tile_width:Float, ?tile_height:Float):FlxPoint

returns a point at the bottom-center of a tile of a given width and height. ex. pos.place_on_tile_anchor(16) = a point offset from pos by x: 8, and y: 8

 *  @param p			input point
 *  @param tile_width	the width of the tile
 *  @param tile_height	the height of the tile
 *  @return				FlxPoint

@:value({ floor : false })staticinlinesnap_to_grid (p:FlxPoint, grid_size:FlxPoint, ?offset:FlxPoint, floor:Bool = false):FlxPoint

Returns a FlxPoint snapped to a grid

Parameters:

p

input

grid_size

grid size as FlxPoint

offset

grid offpoint

floor

whether to floor() or round() to grid

Returns:

FlxPoint

@:value({ put : true })staticinlineto_flxpoint (v:Vec2, put:Bool = true):FlxPoint

staticinlineto_int_point (p:FlxPoint):IntPoint

returns a new IntPoint with the same coordinates, translated to Ints

 *  @param p	input point
 *  @return		IntPoint

staticinlineto_vector (p:FlxPoint):Vec2

Returns a Vector from a FlxPoint

 *  @param p	input point
 *  @return		Vector

staticinlinevector_angle (v:FlxPoint):Float

returns the angle of the input vector. ex. ship.velocity.vector_angle() = ship heading in degrees

 *  @param v	input vector
 *  @return		Float

staticinlinevector_length (v:FlxPoint):Float

returns the length of the input vector. ex. ship.velocity.vector_length() = speed of ship

 *  @param p	input vector
 *  @return		Float