AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

Rect2i.Intersect

Method

public Rect2i Intersect(Rect2i rect)

Parameters

rect Rect2i Rectangle to intersect with

Returns

Rect2i

Intersection area

Description

Get a rect representing the intersection area with another rectangle. In other words, the returned rectangle represents the overlapping area between two rectangles.

Example

void Render() {
    // Draw the intersection area of the player and block. Useful for collision debugging.
    if (playerRect.Intersects(blockRect)) {
        var area = playerRect.Intersect(blockRect);
        RB.DrawRect(area, Color.red);
    }
}

See Also

Rect2i.Intersects
Rect2i.IntersectionDepth
Rect2i.Contains