Stores a rectangle.

Static variables

staticread onlypool:IFlxPool<FlxRect>

Static methods

@:value({ Height : 0, Width : 0, Y : 0, X : 0 })staticinlineget(X:Float = 0, Y:Float = 0, Width:Float = 0, Height:Float = 0):FlxRect

Recycle or create new FlxRect. Be sure to put() them back into the pool after you're done with them!

@:value({ Height : 0, Width : 0, Y : 0, X : 0 })staticinlineweak(X:Float = 0, Y:Float = 0, Width:Float = 0, Height:Float = 0):FlxRect

Recycle or create a new FlxRect which will automatically be released to the pool when passed into a flixel function.

Constructor

@:value({ Height : 0, Width : 0, Y : 0, X : 0 })@:keepnew(X:Float = 0, Y:Float = 0, Width:Float = 0, Height:Float = 0)

Variables

bottom:Float

The y coordinate of the bottom of the rectangle.

read onlyisEmpty:Bool

Whether width or height of this rectangle is equal to zero or not.

left:Float

The x coordinate of the left side of the rectangle.

right:Float

The x coordinate of the right side of the rectangle.

top:Float

The y coordinate of the top of the rectangle.

Methods

inlineceil():FlxRect

Rounds x, y, width and height using Math.ceil()

clipTo(rect:FlxRect):FlxRect

Resizes this instance so that it fits within the intersection of the this and the target rect. If there is no overlap between them, The result is an empty rect.

Parameters:

rect

Rectangle to check intersection against

Returns:

This rect, useful for chaining

Available since

5.9.0

.

inlinecontainsPoint(point:FlxPoint):Bool

Returns true if this FlxRect contains the FlxPoint

Parameters:

point

The FlxPoint to check

Returns:

True if the FlxPoint is within this FlxRect, otherwise false

inlinecontainsXY(xPos:Float, yPos:Float):Bool

Returns true if this FlxRect contains the FlxPoint

Parameters:

xPos

The x position to check

yPos

The y position to check

Returns:

True if the FlxPoint is within this FlxRect, otherwise false

inlinecopyFrom(Rect:FlxRect):FlxRect

Helper function, just copies the values from the specified rectangle.

Parameters:

Rect

Any FlxRect.

Returns:

A reference to itself.

inlinecopyFromFlash(FlashRect:Rectangle):FlxRect

Helper function, just copies the values from the specified Flash rectangle.

Parameters:

FlashRect

Any Rectangle.

Returns:

A reference to itself.

inlinecopyTo(Rect:FlxRect):FlxRect

Helper function, just copies the values from this rectangle to the specified rectangle.

Parameters:

Point

Any FlxRect.

Returns:

A reference to the altered rectangle parameter.

inlinecopyToFlash(?FlashRect:Null<Rectangle>):Rectangle

Helper function, just copies the values from this rectangle to the specified Flash rectangle.

Parameters:

Point

Any Rectangle.

Returns:

A reference to the altered rectangle parameter.

destroy():Void

Necessary for IFlxDestroyable.

inlineequals(rect:FlxRect):Bool

Checks if this rectangle's properties are equal to properties of provided rect.

Parameters:

rect

Rectangle to check equality to.

Returns:

Whether both rectangles are equal.

inlinefloor():FlxRect

Rounds x, y, width and height using Math.floor()

inlinefromTwoPoints(Point1:FlxPoint, Point2:FlxPoint):FlxRect

Calculation of bounding box for two points

Parameters:

point1

first point to calculate bounding box

point2

second point to calculate bounding box

Returns:

this rectangle filled with the position and size of bounding box for two specified points

getMidpoint(?point:FlxPoint):FlxPoint

The middle point of this rect

Parameters:

point

The point to hold the result, if null a new one is created

Available since

5.9.0

.

getRotatedBounds(degrees:Float, ?origin:FlxPoint, ?newRect:FlxRect):FlxRect

Calculates the globally aligned bounding box of a FlxRect with the given angle and origin.

Parameters:

degrees

The rotation, in degrees of the rect.

origin

The relative pivot point, or the point that the rectangle rotates around. if null , the top-left (or 0,0) is used.

newRect

Optional output FlxRect, if null, a new one is created. Note: If you like, you can pass in the input rect to manipulate it. ex: rect.calcRotatedBounds(angle, null, rect)

Returns:

A globally aligned FlxRect that fully contains the input rectangle.

Available since

4.11.0

.

intersection(rect:FlxRect, ?result:FlxRect):FlxRect

Returns the area of intersection with specified rectangle. If the rectangles do not intersect, this method returns an empty rectangle.

Parameters:

rect

Rectangle to check intersection against

result

The resulting instance, if null, a new one is created

Returns:

The area of intersection of two rectangles

inlineoffset(dx:Float, dy:Float):FlxRect

inlineoverlaps(rect:FlxRect):Bool

Checks to see if this rectangle overlaps another

Parameters:

rect

The other rectangle

Returns:

Whether the two rectangles overlap

inlineput():Void

Add this FlxRect to the recycling pool.

inlineputWeak():Void

Add this FlxRect to the recycling pool if it's a weak reference (allocated via weak()).

inlineround():FlxRect

Rounds x, y, width and height using Math.round()

@:value({ Height : 0, Width : 0, Y : 0, X : 0 })inlineset(X:Float = 0, Y:Float = 0, Width:Float = 0, Height:Float = 0):FlxRect

Fill this rectangle with the data provided.

Parameters:

X

The X-coordinate of the point in space.

Y

The Y-coordinate of the point in space.

Width

Desired width of the rectangle.

Height

Desired height of the rectangle.

Returns:

A reference to itself.

inlinesetPosition(x:Float, y:Float):FlxRect

Shortcut for setting both x and y.

inlinesetSize(Width:Float, Height:Float):FlxRect

Shortcut for setting both width and Height.

Parameters:

Width

The new sprite width.

Height

The new sprite height.

inlinetoString():String

Convert object to readable string name. Useful for debugging, save games, etc.

inlineunion(Rect:FlxRect):FlxRect

Add another rectangle to this one by filling in the horizontal and vertical space between the two rectangles.

Parameters:

Rect

The second FlxRect to add to this one

Returns:

The changed FlxRect

inlineunionWithPoint(Point:FlxPoint):FlxRect

Add another point to this rectangle one by filling in the horizontal and vertical space between the point and this rectangle.

Parameters:

Point

point to add to this one

Returns:

The changed FlxRect