Rect2
(reference) is composed of two properties, pos
(position
in 3.0+) and size
which of the Vector2
type (reference).
Vector2
is indeed composed of two floats, so to get it snapped to integer values, you can use for example Vector2.floor()
(reference) which will give you the integral part of the components.
So this might give you want you need:
var my_rect = Rect2(Vector2(10.3, -52.9), Vector2(10.0, 23.4))
my_rect.pos = my_rect.pos.floor()
my_rect.size = my_rect.size.floor()
print(my_rect) # should be ((10.0, -52.0), (10.0, 23.0))
(pseudo code, untested)
What's in the Rect2
/Vector2
s is still floats, but without decimal points; if you then need integers to make calculations, you can cast to int with the int()
function, e.g. int(my_rect.size.y) # should be 23
.