Merge pull request #49000 from KoBeWi/iCoords
Change frame_coords to Vector2i
This commit is contained in:
commit
635d0c9b44
7 changed files with 21 additions and 21 deletions
|
@ -64,7 +64,7 @@
|
|||
<member name="frame" type="int" setter="set_frame" getter="get_frame" default="0">
|
||||
Current frame to display from sprite sheet. [member hframes] or [member vframes] must be greater than 1.
|
||||
</member>
|
||||
<member name="frame_coords" type="Vector2" setter="set_frame_coords" getter="get_frame_coords" default="Vector2( 0, 0 )">
|
||||
<member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i( 0, 0 )">
|
||||
Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member hframes] or [member vframes] must be greater than 1.
|
||||
</member>
|
||||
<member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1">
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<member name="frame" type="int" setter="set_frame" getter="get_frame" default="0">
|
||||
Current frame to display from sprite sheet. [member hframes] or [member vframes] must be greater than 1.
|
||||
</member>
|
||||
<member name="frame_coords" type="Vector2" setter="set_frame_coords" getter="get_frame_coords" default="Vector2( 0, 0 )">
|
||||
<member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i( 0, 0 )">
|
||||
Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member hframes] or [member vframes] must be greater than 1.
|
||||
</member>
|
||||
<member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1">
|
||||
|
|
|
@ -741,7 +741,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
|
|||
|
||||
if (use_keying_next()) {
|
||||
if (property == "frame_coords" && (object->is_class("Sprite2D") || object->is_class("Sprite3D"))) {
|
||||
Vector2 new_coords = object->get(property);
|
||||
Vector2i new_coords = object->get(property);
|
||||
new_coords.x++;
|
||||
if (new_coords.x >= object->get("hframes").operator int64_t()) {
|
||||
new_coords.x = 0;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -109,8 +109,8 @@ public:
|
|||
void set_frame(int p_frame);
|
||||
int get_frame() const;
|
||||
|
||||
void set_frame_coords(const Vector2 &p_coord);
|
||||
Vector2 get_frame_coords() const;
|
||||
void set_frame_coords(const Vector2i &p_coord);
|
||||
Vector2i get_frame_coords() const;
|
||||
|
||||
void set_vframes(int p_amount);
|
||||
int get_vframes() const;
|
||||
|
|
|
@ -551,15 +551,15 @@ int Sprite3D::get_frame() const {
|
|||
return frame;
|
||||
}
|
||||
|
||||
void Sprite3D::set_frame_coords(const Vector2 &p_coord) {
|
||||
ERR_FAIL_INDEX(int(p_coord.x), hframes);
|
||||
ERR_FAIL_INDEX(int(p_coord.y), vframes);
|
||||
void Sprite3D::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 Sprite3D::get_frame_coords() const {
|
||||
return Vector2(frame % hframes, frame / hframes);
|
||||
Vector2i Sprite3D::get_frame_coords() const {
|
||||
return Vector2i(frame % hframes, frame / hframes);
|
||||
}
|
||||
|
||||
void Sprite3D::set_vframes(int p_amount) {
|
||||
|
@ -657,7 +657,7 @@ void Sprite3D::_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");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect");
|
||||
|
|
|
@ -176,8 +176,8 @@ public:
|
|||
void set_frame(int p_frame);
|
||||
int get_frame() const;
|
||||
|
||||
void set_frame_coords(const Vector2 &p_coord);
|
||||
Vector2 get_frame_coords() const;
|
||||
void set_frame_coords(const Vector2i &p_coord);
|
||||
Vector2i get_frame_coords() const;
|
||||
|
||||
void set_vframes(int p_amount);
|
||||
int get_vframes() const;
|
||||
|
|
Loading…
Reference in a new issue