phaser4-rex-plugins
Version:
74 lines (62 loc) • 1.78 kB
JavaScript
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
import Class from '../../object/Class.js';
/**
* @classdesc
* Defines a Point in 2D space, with an x and y component.
*
* @class Point
* @memberof Phaser.Geom
* @constructor
* @since 3.0.0
*
* @param {number} [x=0] - The x coordinate of this Point.
* @param {number} [y=x] - The y coordinate of this Point.
*/
var Point = new Class({
initialize:
function Point(x, y) {
if (x === undefined) { x = 0; }
if (y === undefined) { y = x; }
/**
* The x coordinate of this Point.
*
* @name Phaser.Geom.Point#x
* @type {number}
* @default 0
* @since 3.0.0
*/
this.x = x;
/**
* The y coordinate of this Point.
*
* @name Phaser.Geom.Point#y
* @type {number}
* @default 0
* @since 3.0.0
*/
this.y = y;
},
/**
* Set the x and y coordinates of the point to the given values.
*
* @method Phaser.Geom.Point#setTo
* @since 3.0.0
*
* @param {number} [x=0] - The x coordinate of this Point.
* @param {number} [y=x] - The y coordinate of this Point.
*
* @return {Phaser.Geom.Point} This Point object.
*/
setTo: function (x, y) {
if (x === undefined) { x = 0; }
if (y === undefined) { y = x; }
this.x = x;
this.y = y;
return this;
}
});
export default Point;