Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.27 KB

instance_position_top.md

File metadata and controls

35 lines (24 loc) · 1.27 KB

Home > Community Toolbox Reference > Collision utilities

instance_position_top

Go to source

Finds the instance at the given position with the least depth. If no instance is at the position, noone is returned.

Arguments
Argument Type Usage Description
x Real Required The x coordinate of the point to check.
y Real Required The y coordinate of the point to check.
obj Asset.GMObject,Constant.All,Array Required The object(s) to find at the given position.
Returns

Id.Instance

Example

The following code chooses the topmost (or frontmost) interactible instance in a point-and-click game, and potentially performs interactions on it.

hover_interactible = instance_position_top(mouse_x, mouse_y, par_Interactible);
with (hover_interactible) {
    other.tooltip = tooltip;
    if (mouse_check_button_pressed(mb_left))
        begin_interaction();
}

Update history

  • 24.6.0 - Created a function to find the least-depth instance at the given position.