Skip to content

Commit 5930a90

Browse files
committed
added clone function to Line
1 parent 8c0a400 commit 5930a90

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/geom/Line.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,27 @@ Phaser.Line.prototype = {
182182

183183
return results;
184184

185+
},
186+
187+
/**
188+
* Returns a new Line object with the same values for the start and end properties as this Line object.
189+
* @method Phaser.Line#clone
190+
* @param {Phaser.Line} output - Optional Line object. If given the values will be set into the object, otherwise a brand new Line object will be created and returned.
191+
* @return {Phaser.Line} The cloned Line object.
192+
*/
193+
clone: function (output) {
194+
195+
if (typeof output === "undefined" || output === null)
196+
{
197+
output = new Phaser.Line(this.start.x, this.start.y, this.end.x, this.end.y);
198+
}
199+
else
200+
{
201+
output.setTo(this.start.x, this.start.y, this.start.x, this.start.y);
202+
}
203+
204+
return output;
205+
185206
}
186207

187208
};

0 commit comments

Comments
 (0)