pixi.js
    Preparing search index...

    Interface IHitArea

    Interface defining a hit area for pointer interaction. The hit area specifies the region in which pointer events should be captured by a display object.

    // Create a rectangular hit area
    sprite.hitArea = new Rectangle(0, 0, 100, 100);

    // Create a circular hit area
    sprite.hitArea = new Circle(50, 50, 50);

    // Custom hit area implementation
    sprite.hitArea = {
    contains(x: number, y: number) {
    // Custom hit testing logic
    return x >= 0 && x <= 100 && y >= 0 && y <= 100;
    }
    };
    • Hit areas override the default bounds-based hit testing
    • Can improve performance by simplifying hit tests
    • Useful for irregular shapes or precise interaction areas
    • Common implementations include Rectangle, Circle, Polygon
    interface IHitArea {
        contains(x: number, y: number): boolean;
    }
    Index

    Methods

    Methods

    • Checks if the given coordinates are inside this hit area.

      Parameters

      • x: number

        The x coordinate to check

      • y: number

        The y coordinate to check

      Returns boolean

      True if the coordinates are inside the hit area