phaser
Version:
A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers from the team at Phaser Studio Inc.
88 lines (75 loc) • 1.96 kB
JavaScript
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2025 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var GEOM_CONST = require('../const');
/**
* @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 geometry constant type of this object: `GEOM_CONST.POINT`.
* Used for fast type comparisons.
*
* @name Phaser.Geom.Point#type
* @type {number}
* @readonly
* @since 3.19.0
*/
this.type = GEOM_CONST.POINT;
/**
* 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 {this} 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;
}
});
module.exports = Point;