Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
Rect2i¶
A 2D axis-aligned bounding box using integer coordinates.
Description¶
The Rect2i built-in Variant type represents an axis-aligned rectangle in a 2D space, using integer coordinates. It is defined by its position and size, which are Vector2i. Because it does not rotate, it is frequently used for fast overlap tests (see intersects).
For floating-point coordinates, see Rect2.
Note: Negative values for size are not supported. With negative size, most Rect2i methods do not work correctly. Use abs to get an equivalent Rect2i with a non-negative size.
Note: In a boolean context, a Rect2i evaluates to false
if both position and size are zero (equal to Vector2i.ZERO). Otherwise, it always evaluates to true
.
Примітка
There are notable differences when using this API with C#. See Відмінності API C# в GDScript for more information.
Tutorials¶
Properties¶
|
||
|
||
|
Constructors¶
Rect2i ( ) |
|
Methods¶
abs ( ) const |
|
get_area ( ) const |
|
get_center ( ) const |
|
grow_individual ( int left, int top, int right, int bottom ) const |
|
has_area ( ) const |
|
intersection ( Rect2i b ) const |
|
intersects ( Rect2i b ) const |
|
Operators¶
operator != ( Rect2i right ) |
|
operator == ( Rect2i right ) |
Property Descriptions¶
Vector2i end = Vector2i(0, 0)
The ending point. This is usually the bottom-right corner of the rectangle, and is equivalent to position + size
. Setting this point affects the size.