Skip to content

Commit 4704745

Browse files
committed
Optional vec2.
1 parent 917dc8f commit 4704745

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

src/geom/line/Line.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,29 +150,41 @@ var Line = new Class({
150150
},
151151

152152
/**
153-
* [description]
153+
* Returns a Vector2 object that corresponds to the start of this Line.
154154
*
155155
* @method Phaser.Geom.Line#getPointA
156156
* @since 3.0.0
157157
*
158-
* @return {Phaser.Math.Vector2} [description]
158+
* @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created.
159+
*
160+
* @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line.
159161
*/
160-
getPointA: function ()
162+
getPointA: function (vec2)
161163
{
162-
return new Vector2(this.x1, this.y1);
164+
if (vec2 === undefined) { vec2 = new Vector2(); }
165+
166+
vec2.setTo(this.x1, this.y1);
167+
168+
return vec2;
163169
},
164170

165171
/**
166-
* [description]
172+
* Returns a Vector2 object that corresponds to the start of this Line.
167173
*
168174
* @method Phaser.Geom.Line#getPointB
169175
* @since 3.0.0
170176
*
171-
* @return {Phaser.Math.Vector2} [description]
177+
* @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created.
178+
*
179+
* @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line.
172180
*/
173-
getPointB: function ()
181+
getPointB: function (vec2)
174182
{
175-
return new Vector2(this.x2, this.y2);
183+
if (vec2 === undefined) { vec2 = new Vector2(); }
184+
185+
vec2.setTo(this.x2, this.y2);
186+
187+
return vec2;
176188
},
177189

178190
/**

0 commit comments

Comments
 (0)