FlxCollision

@link http://www.photonstorm.com

Static methods

staticcalcRectEntry(rect:FlxRect, start:FlxPoint, end:FlxPoint, ?result:FlxPoint):Null<FlxPoint>

Calculates at which point where the given line, from start to end, first enters the rect. If the line starts inside the rect, a copy of start is returned. If the line never enters the rect, null is returned.

Note: If a result vector is supplied and the line is outside the rect, null is returned and the supplied result is unchanged

Parameters:

rect

The rect being entered

start

The start of the line

end

The end of the line

result

Optional result vector, to avoid creating a new instance to be returned. Only returned if the line enters the rect.

Returns:

The point of entry of the line into the rect, if possible.

Available since

5.0.0

.

staticinlinecalcRectExit(rect:FlxRect, start:FlxPoint, end:FlxPoint, result:Null<FlxPoint>):Null<FlxPoint>

Calculates at which point where the given line, from start to end, was last inside the rect. If the line ends inside the rect, a copy of end is returned. If the line is never inside the rect, null is returned.

Note: If a result vector is supplied and the line is outside the rect, null is returned and the supplied result is unchanged

Parameters:

rect

The rect being exited

start

The start of the line

end

The end of the line

result

Optional result vector, to avoid creating a new instance to be returned. Only returned if the line enters the rect.

Returns:

The point of exit of the line from the rect, if possible.

Available since

5.0.0

.

@:value({ adjustWorldBounds : false, placeOutside : true })staticcreateCameraWall(camera:FlxCamera, placeOutside:Bool = true, thickness:Int, adjustWorldBounds:Bool = false):FlxGroup

Creates a "wall" around the given camera which can be used for FlxSprite collision

Parameters:

camera

The FlxCamera to use for the wall bounds (can be FlxG.camera for the current one)

placeOutside

Whether to place the camera wall outside or inside

thickness

The thickness of the wall in pixels

adjustWorldBounds

Adjust the FlxG.worldBounds based on the wall (true) or leave alone (false)

Returns:

FlxGroup The 4 FlxTileblocks that are created are placed into this FlxGroup which should be added to your State

@:value({ alphaTolerance : 1 })staticpixelPerfectCheck(contact:FlxSprite, target:FlxSprite, alphaTolerance:Int = 1, ?camera:FlxCamera):Bool

A Pixel Perfect Collision check between two FlxSprites. It will do a bounds check first, and if that passes it will run a pixel perfect match on the intersecting area. Works with rotated and animated sprites. May be slow, so use it sparingly.

Parameters:

contact

The first FlxSprite to test against

target

The second FlxSprite to test again, sprite order is irrelevant

alphaTolerance

The tolerance value above which alpha pixels are included. Default to 1 (anything that is not fully invisible).

camera

If the collision is taking place in a camera other than FlxG.camera (the default/current) then pass it here

Returns:

Whether the sprites collide

@:value({ alphaTolerance : 1 })staticpixelPerfectPointCheck(worldX:Int, worldY:Int, target:FlxSprite, alphaTolerance:Int = 1):Bool

Deprecated: "Use sprite.pixelsOverlapPoint instead"

Checks to see if a point in 2D world space overlaps this FlxSprite object's current displayed pixels. This check is ALWAYS made in screen space, and factors in scale, angle, offset, origin, and scrollFactor.

Parameters:

worldX

The x coordinate of the point given in world space

worldY

The y coordinate of the point given in world space

sprite

The FlxSprite to check the point against

alphaTolerance

The alpha tolerance for with pixels are considered "solid". Defaults to 1 (anything that is not fully invisible).

Returns:

Whether the x/y point overlaps with the sprite, false if not