소스 검색

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}
 }
 
+// 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.
 // Returns the pointer to this updated vector.
 func (v *Vector2) Set(x, y float32) *Vector2 {