summaryrefslogtreecommitdiff
path: root/scene/2d/sprite_2d.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-05-23 23:11:49 +0200
committerGitHub <noreply@github.com>2021-05-23 23:11:49 +0200
commit635d0c9b449e34267b52a237f7ce21838d90b6ce (patch)
tree5ef32ff3599ca5f6112354061df445ded724631d /scene/2d/sprite_2d.cpp
parent809948f977294c8bb61a6e46dfa132ea6e0478d8 (diff)
parent5605454981012ee40ca9e4cd8249fa3fba6092ef (diff)
Merge pull request #49000 from KoBeWi/iCoords
Change frame_coords to Vector2i
Diffstat (limited to 'scene/2d/sprite_2d.cpp')
-rw-r--r--scene/2d/sprite_2d.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp
index 7c93edbff9..20169b1075 100644
--- a/scene/2d/sprite_2d.cpp
+++ b/scene/2d/sprite_2d.cpp
@@ -254,15 +254,15 @@ int Sprite2D::get_frame() const {
return frame;
}
-void Sprite2D::set_frame_coords(const Vector2 &p_coord) {
- ERR_FAIL_INDEX(int(p_coord.x), hframes);
- ERR_FAIL_INDEX(int(p_coord.y), vframes);
+void Sprite2D::set_frame_coords(const Vector2i &p_coord) {
+ ERR_FAIL_INDEX(p_coord.x, hframes);
+ ERR_FAIL_INDEX(p_coord.y, vframes);
- set_frame(int(p_coord.y) * hframes + int(p_coord.x));
+ set_frame(p_coord.y * hframes + p_coord.x);
}
-Vector2 Sprite2D::get_frame_coords() const {
- return Vector2(frame % hframes, frame / hframes);
+Vector2i Sprite2D::get_frame_coords() const {
+ return Vector2i(frame % hframes, frame / hframes);
}
void Sprite2D::set_vframes(int p_amount) {
@@ -452,7 +452,7 @@ void Sprite2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes");
ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes");
ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "frame_coords", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_frame_coords", "get_frame_coords");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "frame_coords", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_frame_coords", "get_frame_coords");
ADD_GROUP("Region", "region_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region_enabled"), "set_region_enabled", "is_region_enabled");