With this function you can bind any function that has previously been defined to a given instance or struct, creating a method variable that can be used later. You supply the instance ID to use (it must be an instance that is active and in the room, and can't be an object ID) or a struct reference, as well as the ID of the function that you want to bind. The function will return a method which can be called from the variable it is assigned to (see the code example below). It is worth noting that you can bind built-in functions as well as user defined functions, and you can also supply undefined as the instance/struct argument meaning that the current self scope will be used for the binding.



method(struct_ref_or_instance_id, function);

Argument Description
struct_ref_or_instance_id The unique reference or ID value of the struct or instance to use (or undefined for self)
function The ID of the function to use






var _inst = instance_position(mouse_x, mouse_y, obj_Enemy);
if instance_exists(_inst)
    enemy_func = method(_inst, enemy_ai);

The above code will check to see if an instance exists at the given position and if it does then a function is bound to the instance and returned as the method variable "enemy_func".