/** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ var Class = require('../../utils/Class'); var Vector2 = require('../../math/Vector2'); /** * @classdesc * [description] * * @class MoveTo * @memberOf Phaser.Curves * @constructor * @since 3.0.0 * * @param {number} [x] - [description] * @param {number} [y] - [description] */ var MoveTo = new Class({ initialize: function MoveTo (x, y) { // Skip length calcs in paths /** * [description] * * @name Phaser.Curves.MoveTo#active * @type {boolean} * @default false * @since 3.0.0 */ this.active = false; /** * [description] * * @name Phaser.Curves.MoveTo#p0 * @type {Phaser.Math.Vector2} * @since 3.0.0 */ this.p0 = new Vector2(x, y); }, /** * Get point at relative position in curve according to length. * * @method Phaser.Curves.MoveTo#getPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. */ getPoint: function (t, out) { if (out === undefined) { out = new Vector2(); } return out.copy(this.p0); }, /** * [description] * * @method Phaser.Curves.MoveTo#getPointAt * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] */ getPointAt: function (u, out) { return this.getPoint(u, out); }, /** * Gets the resolution of this curve. * * @method Phaser.Curves.MoveTo#getResolution * @since 3.0.0 * * @return {number} The resolution of this curve. For a MoveTo the value is always 1. */ getResolution: function () { return 1; }, /** * Gets the length of this curve. * * @method Phaser.Curves.MoveTo#getLength * @since 3.0.0 * * @return {number} The length of this curve. For a MoveTo the value is always 0. */ getLength: function () { return 0; }, /** * [description] * * @method Phaser.Curves.MoveTo#toJSON * @since 3.0.0 * * @return {JSONCurve} [description] */ toJSON: function () { return { type: 'MoveTo', points: [ this.p0.x, this.p0.y ] }; } }); module.exports = MoveTo;