File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var Class = require('../../utils/Class');
88var Contains = require ( './Contains' ) ;
99var GetPoint = require ( './GetPoint' ) ;
1010var GetPoints = require ( './GetPoints' ) ;
11+ var GEOM_CONST = require ( '../const' ) ;
1112var Random = require ( './Random' ) ;
1213
1314/**
@@ -37,6 +38,17 @@ var Circle = new Class({
3738 if ( y === undefined ) { y = 0 ; }
3839 if ( radius === undefined ) { radius = 0 ; }
3940
41+ /**
42+ * The geometry constant type of this object: `GEOM_CONST.CIRCLE`.
43+ * Used for fast type comparisons.
44+ *
45+ * @name Phaser.Geom.Circle#type
46+ * @type {integer }
47+ * @readonly
48+ * @since 3.19.0
49+ */
50+ this . type = GEOM_CONST . CIRCLE ;
51+
4052 /**
4153 * The x position of the center of the circle.
4254 *
Original file line number Diff line number Diff line change 1+ /**
2+ * @author Richard Davey <rich@photonstorm.com>
3+ * @copyright 2019 Photon Storm Ltd.
4+ * @license {@link https://opensource.org/licenses/MIT|MIT License }
5+ */
6+
7+ var GEOM_CONST = {
8+
9+ /**
10+ * A Circle Geometry object type.
11+ *
12+ * @name Phaser.Geom.CIRCLE
13+ * @type {integer }
14+ * @since 3.19.0
15+ */
16+ CIRCLE : 0 ,
17+
18+ /**
19+ * An Ellipse Geometry object type.
20+ *
21+ * @name Phaser.Geom.ELLIPSE
22+ * @type {integer }
23+ * @since 3.19.0
24+ */
25+ ELLIPSE : 1 ,
26+
27+ /**
28+ * A Line Geometry object type.
29+ *
30+ * @name Phaser.Geom.LINE
31+ * @type {integer }
32+ * @since 3.19.0
33+ */
34+ LINE : 2 ,
35+
36+ /**
37+ * A Point Geometry object type.
38+ *
39+ * @name Phaser.Geom.POINT
40+ * @type {integer }
41+ * @since 3.19.0
42+ */
43+ POINT : 3 ,
44+
45+ /**
46+ * A Polygon Geometry object type.
47+ *
48+ * @name Phaser.Geom.POLYGON
49+ * @type {integer }
50+ * @since 3.19.0
51+ */
52+ POLYGON : 4 ,
53+
54+ /**
55+ * A Rectangle Geometry object type.
56+ *
57+ * @name Phaser.Geom.RECTANGLE
58+ * @type {integer }
59+ * @since 3.19.0
60+ */
61+ RECTANGLE : 5 ,
62+
63+ /**
64+ * A Triangle Geometry object type.
65+ *
66+ * @name Phaser.Geom.TRIANGLE
67+ * @type {integer }
68+ * @since 3.19.0
69+ */
70+ TRIANGLE : 6
71+
72+ } ;
73+
74+ module . exports = GEOM_CONST ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var Class = require('../../utils/Class');
88var Contains = require ( './Contains' ) ;
99var GetPoint = require ( './GetPoint' ) ;
1010var GetPoints = require ( './GetPoints' ) ;
11+ var GEOM_CONST = require ( '../const' ) ;
1112var Random = require ( './Random' ) ;
1213
1314/**
@@ -39,6 +40,17 @@ var Ellipse = new Class({
3940 if ( width === undefined ) { width = 0 ; }
4041 if ( height === undefined ) { height = 0 ; }
4142
43+ /**
44+ * The geometry constant type of this object: `GEOM_CONST.ELLIPSE`.
45+ * Used for fast type comparisons.
46+ *
47+ * @name Phaser.Geom.Ellipse#type
48+ * @type {integer }
49+ * @readonly
50+ * @since 3.19.0
51+ */
52+ this . type = GEOM_CONST . ELLIPSE ;
53+
4254 /**
4355 * The x position of the center of the ellipse.
4456 *
Original file line number Diff line number Diff line change 44 * @license {@link https://opensource.org/licenses/MIT|MIT License }
55 */
66
7+ var CONST = require ( './const' ) ;
8+ var Extend = require ( '../utils/object/Extend' ) ;
9+
710/**
811 * @namespace Phaser.Geom
912 */
1013
11- module . exports = {
14+ var Geom = {
1215
1316 Circle : require ( './circle' ) ,
1417 Ellipse : require ( './ellipse' ) ,
@@ -20,3 +23,8 @@ module.exports = {
2023 Triangle : require ( './triangle' )
2124
2225} ;
26+
27+ // Merge in the consts
28+ Geom = Extend ( false , Geom , CONST ) ;
29+
30+ module . exports = Geom ;
Original file line number Diff line number Diff line change 77var Class = require ( '../../utils/Class' ) ;
88var GetPoint = require ( './GetPoint' ) ;
99var GetPoints = require ( './GetPoints' ) ;
10+ var GEOM_CONST = require ( '../const' ) ;
1011var Random = require ( './Random' ) ;
1112var Vector2 = require ( '../../math/Vector2' ) ;
1213
@@ -35,6 +36,17 @@ var Line = new Class({
3536 if ( x2 === undefined ) { x2 = 0 ; }
3637 if ( y2 === undefined ) { y2 = 0 ; }
3738
39+ /**
40+ * The geometry constant type of this object: `GEOM_CONST.LINE`.
41+ * Used for fast type comparisons.
42+ *
43+ * @name Phaser.Geom.Line#type
44+ * @type {integer }
45+ * @readonly
46+ * @since 3.19.0
47+ */
48+ this . type = GEOM_CONST . LINE ;
49+
3850 /**
3951 * The x coordinate of the lines starting point.
4052 *
Original file line number Diff line number Diff line change 55 */
66
77var Class = require ( '../../utils/Class' ) ;
8+ var GEOM_CONST = require ( '../const' ) ;
89
910/**
1011 * @classdesc
@@ -27,6 +28,17 @@ var Point = new Class({
2728 if ( x === undefined ) { x = 0 ; }
2829 if ( y === undefined ) { y = x ; }
2930
31+ /**
32+ * The geometry constant type of this object: `GEOM_CONST.POINT`.
33+ * Used for fast type comparisons.
34+ *
35+ * @name Phaser.Geom.Point#type
36+ * @type {integer }
37+ * @readonly
38+ * @since 3.19.0
39+ */
40+ this . type = GEOM_CONST . POINT ;
41+
3042 /**
3143 * The x coordinate of this Point.
3244 *
Original file line number Diff line number Diff line change 77var Class = require ( '../../utils/Class' ) ;
88var Contains = require ( './Contains' ) ;
99var GetPoints = require ( './GetPoints' ) ;
10+ var GEOM_CONST = require ( '../const' ) ;
1011
1112/**
1213 * @classdesc
@@ -37,6 +38,17 @@ var Polygon = new Class({
3738
3839 function Polygon ( points )
3940 {
41+ /**
42+ * The geometry constant type of this object: `GEOM_CONST.POLYGON`.
43+ * Used for fast type comparisons.
44+ *
45+ * @name Phaser.Geom.Polygon#type
46+ * @type {integer }
47+ * @readonly
48+ * @since 3.19.0
49+ */
50+ this . type = GEOM_CONST . POLYGON ;
51+
4052 /**
4153 * The area of this Polygon.
4254 *
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var Class = require('../../utils/Class');
88var Contains = require ( './Contains' ) ;
99var GetPoint = require ( './GetPoint' ) ;
1010var GetPoints = require ( './GetPoints' ) ;
11+ var GEOM_CONST = require ( '../const' ) ;
1112var Line = require ( '../line/Line' ) ;
1213var Random = require ( './Random' ) ;
1314
@@ -36,6 +37,17 @@ var Rectangle = new Class({
3637 if ( width === undefined ) { width = 0 ; }
3738 if ( height === undefined ) { height = 0 ; }
3839
40+ /**
41+ * The geometry constant type of this object: `GEOM_CONST.RECTANGLE`.
42+ * Used for fast type comparisons.
43+ *
44+ * @name Phaser.Geom.Rectangle#type
45+ * @type {integer }
46+ * @readonly
47+ * @since 3.19.0
48+ */
49+ this . type = GEOM_CONST . RECTANGLE ;
50+
3951 /**
4052 * The X coordinate of the top left corner of the Rectangle.
4153 *
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ var Class = require('../../utils/Class');
88var Contains = require ( './Contains' ) ;
99var GetPoint = require ( './GetPoint' ) ;
1010var GetPoints = require ( './GetPoints' ) ;
11+ var GEOM_CONST = require ( '../const' ) ;
1112var Line = require ( '../line/Line' ) ;
1213var Random = require ( './Random' ) ;
1314
@@ -42,6 +43,17 @@ var Triangle = new Class({
4243 if ( x3 === undefined ) { x3 = 0 ; }
4344 if ( y3 === undefined ) { y3 = 0 ; }
4445
46+ /**
47+ * The geometry constant type of this object: `GEOM_CONST.TRIANGLE`.
48+ * Used for fast type comparisons.
49+ *
50+ * @name Phaser.Geom.Triangle#type
51+ * @type {integer }
52+ * @readonly
53+ * @since 3.19.0
54+ */
55+ this . type = GEOM_CONST . TRIANGLE ;
56+
4557 /**
4658 * `x` coordinate of the first point.
4759 *
You can’t perform that action at this time.
0 commit comments