Show / Hide Table of Contents

    Interface IHitTest

    Responsible for returning the current object that is located under the mouse position.

    Namespace: AGS.API
    Assembly: AGS.API.dll
    Syntax
    public interface IHitTest

    Properties

    | Improve this Doc View Source

    ObjectAtMousePosition

    Gets the object at the mouse position (this ignores objects that are not visible or enabled). If there is more than one object in that position it returns the one in front.

    Declaration
    IObject ObjectAtMousePosition { get; }
    Property Value
    Type Description
    IObject

    The object at mouse position.

    Methods

    | Improve this Doc View Source

    GetObjectAt(Single, Single, Predicate<IObject>)

    Gets the object at the (x,y) world position. If there is more than one object in that position it returns the one in front. You can also optionally pass a filter which allows to ignore specific objects from the hit tests.

    Note that if you just need the object at the mouse position, you should use ObjectAtMousePosition, this is cached every tick and will be faster.

    Declaration
    IObject GetObjectAt(float x, float y, Predicate<IObject> filter = null)
    Parameters
    Type Name Description
    System.Single x

    The x coordinate (in world co-ordinates).

    System.Single y

    The y coordinate (in world co-ordinates).

    System.Predicate<IObject> filter

    An optional filter.

    Returns
    Type Description
    IObject

    The IObject at that world position.

    Examples

    To get GUIs only you can do something like:

    var gui = hitTest.GetObjectAt(200, 100, obj => obj is IUIControl);
    if (gui == null) await cHero.SayAsync("There's no GUI at (200,100)");
    else await cHero.SayAsync($"I see at {gui.DisplayName} at (200,100)!");
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX