浏览代码

Merge pull request #170 from wolfgarnet/clone-vecter2

Added Clone() for Vector2
Daniel Salvadori 5 年之前
父节点
当前提交
54a1202382
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      math32/vector2.go

+ 6 - 0
math32/vector2.go

@@ -23,6 +23,12 @@ func NewVec2() *Vector2 {
 	return &Vector2{X: 0, Y: 0}
 	return &Vector2{X: 0, Y: 0}
 }
 }
 
 
+// Clone returns a copy of this vector
+func (v *Vector2) Clone() *Vector2 {
+
+	return NewVector2(v.X, v.Y)
+}
+
 // Set sets this vector X and Y components.
 // Set sets this vector X and Y components.
 // Returns the pointer to this updated vector.
 // Returns the pointer to this updated vector.
 func (v *Vector2) Set(x, y float32) *Vector2 {
 func (v *Vector2) Set(x, y float32) *Vector2 {