浏览代码

Add missing Vector2::operator Vector2i()

Zhehang Ding 3 年之前
父节点
当前提交
df0e28fe43
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 1 0
      include/godot_cpp/variant/vector2.hpp
  2. 5 0
      src/variant/vector2.cpp

+ 1 - 0
include/godot_cpp/variant/vector2.hpp

@@ -151,6 +151,7 @@ public:
 	real_t aspect() const { return width / height; }
 
 	operator String() const;
+	operator Vector2i() const;
 
 	inline Vector2() {}
 	inline Vector2(real_t p_x, real_t p_y) {

+ 5 - 0
src/variant/vector2.cpp

@@ -31,6 +31,7 @@
 #include <godot_cpp/core/error_macros.hpp>
 #include <godot_cpp/variant/string.hpp>
 #include <godot_cpp/variant/vector2.hpp>
+#include <godot_cpp/variant/vector2i.hpp>
 
 namespace godot {
 
@@ -38,6 +39,10 @@ Vector2::operator String() const {
 	return String::num(x, 5) + ", " + String::num(y, 5);
 }
 
+Vector2::operator Vector2i() const {
+	return Vector2i(x, y);
+}
+
 real_t Vector2::angle() const {
 	return Math::atan2(y, x);
 }