Common conditions

The following conditions are common to several plugins.

Angle

Note angles in Construct 2 start with 0 degrees facing right and increment clockwise.

Is between angles
True if the object's current angle is between the two given angles in degrees. The first and second angles must be in clockwise order. That is, Is between 0 and 45 degrees is true if the object is in a 45 degree area, but Is between 45 and 0 degrees is true if the object is in the 315 degree area from 45 degrees through 0 degrees.

Is clockwise from
True if the object's current angle is clockwise from the given angle in degrees. Invert to test if the object is anticlockwise from the given angle. For example, an object at 45 degrees is clockwise from 0 degrees, but an object at 0 degrees is anticlockwise from 45 degrees.

Is within angle
True if the object's current angle is within a number of degrees of another angle. This is more reliable than testing if the object's angle exactly equals an angle, e.g. Is within 0.5 degrees of 90 degrees is probably better than Angle equals 90 degrees, since there are many cases an object can be very close to, but not exactly, 90 degrees.

Appearance

Compare opacity
Compare the object's current opacity, from 0 (transparent) to 100 (opaque).

Is visible
True if the object is currently visible. Invert to test if invisible. This only tests the visibility set by the Set visible action; it is not affected by the object being offscreen, having 0 opacity, or being on an invisible layer.

Instance variables

Compare instance variable
Compare the current value of one of the object's instance variables.

Is boolean instance variable set
Test if one of the object's boolean instance variables is set to true. Invert the condition to test if false.

Pick highest/lowest
Pick the single instance with the highest or the lowest instance variable value of all the instances. Note this still only picks a single instance even if multiple instances have the same highest or lowest value; in this case an arbitrary instance is selected.

Misc

On created
On destroyed
Triggered for each instance that is created or destroyed during the running of the game. On created is also trigged for each object already on a layout when the layout starts. For example, a one-shot particle effect could be spawned every time an object is created, and an explosion created every time the object is destroyed. These conditions are analogous to constructors and destructors in traditional programming languages (commands which run at the creation and destruction of an object). Be careful not to create an object of the same type in an On created event (e.g. On Sprite2 created: create Sprite2) since this will create an infinite loop and cause the game to hang.

Pick

Pick by unique ID (UID)
Pick the instance matching a given unique ID (UID) number.

Pick nearest/furthest
Pick the instance either nearest or furthest from a given position in the layout.

Size & Position

Compare width
Compare height
Compare the object's current size, in pixels.

Compare X
Compare Y
Compare the object's current position in the layout, in pixels. Note that objects can be positioned between pixels, e.g. at (5.5, 10.33333). Because of this it's usually a bad idea to rely on an object being at an exact position.

Is on-screen
True if any part of the object's bounding box is within the screen area. This is not affected by the object's visibility or opacity.

Is outside layout
True if the entire object's bounding box is outside the layout area.

Z Order

Is on layer
Pick all instances on a given layer, specified either by its name or zero-based index.

Pick top/bottom
Pick either the top-most or bottom-most instance, taking in to account layers and Z index. For example, the instance at the front of the top most layer is the top instance.

Tags: