Sfoglia il codice sorgente

Merge pull request #170 from wolfgarnet/clone-vecter2

Added Clone() for Vector2
Daniel Salvadori 5 anni fa
parent
commit
54a1202382
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  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 {