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.
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.
5.0.0
.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) |
---|---|
Placement | 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
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
staticpixelPerfectPointCheck(PointX:Int, PointY:Int, Target:FlxSprite, AlphaTolerance:Int = 1):Bool
A Pixel Perfect Collision check between a given x/y coordinate and an FlxSprite
Parameters:
PointX | The x coordinate of the point given in local space (relative to the FlxSprite, not game world coordinates) |
---|---|
PointY | The y coordinate of the point given in local space (relative to the FlxSprite, not game world coordinates) |
Target | The FlxSprite to check the point against |
AlphaTolerance | The alpha tolerance level above which pixels are counted as colliding. Default to 1 (anything that is not fully invisible). |
Returns:
Boolean True if the x/y point collides with the FlxSprite, false if not