instance_activate_region

With this function you can define a region within the room to activate instances that have previously been deactivated. This region can either be flagged as "inside" or "outside" as demonstrated in the following image:

Instance activate region exampleYou can see in the image above that the "apple" instance is always active because, even if the sprite itself doesn't overlap the region, the bounding box does. So, instances are considered to be within the region specified when their bounding box overlaps with it, and the state of the collision mask (precise or not) is not taken into consideration. Note that activation is not instantaneous, and an instance that has been activated in this way will not be considered to be active until the end of the event in which the function was called.

 

Syntax:

instance_activate_region(left, top, width, height, inside);

ArgumentTypeDescription
leftRealThe x coordinate of the left of the rectangular region to activate.
topRealThe y coordinate of the top of the rectangular region to activate.
widthRealThe width of the region to activate.
heightRealThe height of the region to activate.
insideBooleanWhether to activate instances on the inside of the region (true) or the outside (false).

 

Returns:

N/A

 

Example:

instance_deactivate_all(true);
var _vx = camera_get_view_x(view_camera[0]);
var _vy = camera_get_view_y(view_camera[0]);
var _vw = camera_get_view_width(view_camera[0]);
var _vh = camera_get_view_height(view_camera[0]);
instance_activate_region(_vx - 64, _vy - 64, _vw + 128, _vh + 128, false);

The above code deactivates all instances except the one that is running the code and then activates a region within the room.