1-
21var BlendModes = require ( '../../renderer/BlendModes' ) ;
32var Circle = require ( '../../geom/circle/Circle' ) ;
43var CircleContains = require ( '../../geom/circle/Contains' ) ;
@@ -8,14 +7,38 @@ var GameObject = require('../GameObject');
87var Rectangle = require ( '../../geom/rectangle/Rectangle' ) ;
98var RectangleContains = require ( '../../geom/rectangle/Contains' ) ;
109
11- // A Zone is a non-rendering rectangular Game Object that has a position and size.
12- // It has no texture and never renders, but does live on the display list and
13- // can be moved, scaled and rotated like any other Game Object.
14-
15- // The default origin is 0.5, the center of the Zone, the same as with Game Objects.
16- // It's useful for linking to drop zones and input hit areas and has a couple of helper methods specifically for this.
17- // Also useful for object overlap checks, or as a base for your own non-displaying objects.
18-
10+ /**
11+ * A Zone Game Object.
12+ *
13+ * A Zone is a non-rendering rectangular Game Object that has a position and size.
14+ * It has no texture and never displays, but does live on the display list and
15+ * can be moved, scaled and rotated like any other Game Object.
16+ *
17+ * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods
18+ * specifically for this. It is also useful for object overlap checks, or as a base for your own
19+ * non-displaying Game Objects.
20+
21+ * The default origin is 0.5, the center of the Zone, the same as with Game Objects.
22+ *
23+ * @class Zone
24+ * @extends Phaser.GameObjects.GameObject
25+ * @memberOf Phaser.GameObjects
26+ * @constructor
27+ * @since 3.0.0
28+ *
29+ * @extends Phaser.GameObjects.Components.GetBounds
30+ * @extends Phaser.GameObjects.Components.Origin
31+ * @extends Phaser.GameObjects.Components.ScaleMode
32+ * @extends Phaser.GameObjects.Components.Transform
33+ * @extends Phaser.GameObjects.Components.ScrollFactor
34+ * @extends Phaser.GameObjects.Components.Visible
35+ *
36+ * @param {Phaser.Scene } scene - [description]
37+ * @param {number } x - The horizontal position of this Game Object in the world.
38+ * @param {number } y - The vertical position of this Game Object in the world.
39+ * @param {number } [width=1] - The width of the Game Object.
40+ * @param {number } [height=1] - The height of the Game Object.
41+ */
1942var Zone = new Class ( {
2043
2144 Extends : GameObject ,
@@ -40,12 +63,44 @@ var Zone = new Class({
4063
4164 this . setPosition ( x , y ) ;
4265
66+ /**
67+ * The native (un-scaled) width of this Game Object.
68+ *
69+ * @name Phaser.GameObjects.Zone#width
70+ * @type {number }
71+ * @since 3.0.0
72+ */
4373 this . width = width ;
74+
75+ /**
76+ * The native (un-scaled) height of this Game Object.
77+ *
78+ * @name Phaser.GameObjects.Zone#height
79+ * @type {number }
80+ * @since 3.0.0
81+ */
4482 this . height = height ;
4583
84+ /**
85+ * The Blend Mode of the Game Object.
86+ * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into
87+ * display lists without causing a batch flush.
88+ *
89+ * @name Phaser.GameObjects.Zone#blendMode
90+ * @type {integer }
91+ * @since 3.0.0
92+ */
4693 this . blendMode = BlendModes . NORMAL ;
4794 } ,
4895
96+ /**
97+ * The displayed width of this Game Object.
98+ * This value takes into account the scale factor.
99+ *
100+ * @name Phaser.GameObjects.Zone#displayWidth
101+ * @type {number }
102+ * @since 3.0.0
103+ */
49104 displayWidth : {
50105
51106 get : function ( )
@@ -60,6 +115,14 @@ var Zone = new Class({
60115
61116 } ,
62117
118+ /**
119+ * The displayed height of this Game Object.
120+ * This value takes into account the scale factor.
121+ *
122+ * @name Phaser.GameObjects.Zone#displayHeight
123+ * @type {number }
124+ * @since 3.0.0
125+ */
63126 displayHeight : {
64127
65128 get : function ( )
@@ -74,6 +137,18 @@ var Zone = new Class({
74137
75138 } ,
76139
140+ /**
141+ * Sets the size of this Game Object.
142+ *
143+ * @method Phaser.GameObjects.Zone#setSize
144+ * @since 3.0.0
145+ *
146+ * @param {number } width - The width of this Game Object.
147+ * @param {number } height - The height of this Game Object.
148+ * @param {boolean } [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well.
149+ *
150+ * @return {Phaser.GameObjects.Zone } This Game Object.
151+ */
77152 setSize : function ( width , height , resizeInput )
78153 {
79154 if ( resizeInput === undefined ) { resizeInput = true ; }
@@ -90,6 +165,18 @@ var Zone = new Class({
90165 return this ;
91166 } ,
92167
168+ /**
169+ * Sets the display size of this Game Object.
170+ * Calling this will adjust the scale.
171+ *
172+ * @method Phaser.GameObjects.Zone#setDisplaySize
173+ * @since 3.0.0
174+ *
175+ * @param {number } width - The width of this Game Object.
176+ * @param {number } height - The height of this Game Object.
177+ *
178+ * @return {Phaser.GameObjects.Zone } This Game Object.
179+ */
93180 setDisplaySize : function ( width , height )
94181 {
95182 this . displayWidth = width ;
@@ -98,13 +185,34 @@ var Zone = new Class({
98185 return this ;
99186 } ,
100187
101- // Centered on the Zones x/y
188+ /**
189+ * Sets this Zone to be a Circular Drop Zone.
190+ * The circle is centered on this Zones `x` and `y` coordinates.
191+ *
192+ * @method Phaser.GameObjects.Zone#setCircleDropZone
193+ * @since 3.0.0
194+ *
195+ * @param {number } radius - The radius of the Circle that will form the Drop Zone.
196+ *
197+ * @return {Phaser.GameObjects.Zone } This Game Object.
198+ */
102199 setCircleDropZone : function ( radius )
103200 {
104201 return this . setDropZone ( new Circle ( 0 , 0 , radius ) , CircleContains ) ;
105202 } ,
106203
107- // Centered on the Zones x/y position
204+ /**
205+ * Sets this Zone to be a Rectangle Drop Zone.
206+ * The rectangle is centered on this Zones `x` and `y` coordinates.
207+ *
208+ * @method Phaser.GameObjects.Zone#setRectangleDropZone
209+ * @since 3.0.0
210+ *
211+ * @param {number } width - The width of the rectangle drop zone.
212+ * @param {number } height - The height of the rectangle drop zone.
213+ *
214+ * @return {Phaser.GameObjects.Zone } This Game Object.
215+ */
108216 setRectangleDropZone : function ( width , height )
109217 {
110218 var x = - ( width / 2 ) ;
@@ -113,7 +221,17 @@ var Zone = new Class({
113221 return this . setDropZone ( new Rectangle ( x , y , width , height ) , RectangleContains ) ;
114222 } ,
115223
116- // Define your own shape as the drop zone
224+ /**
225+ * Allows you to define your own Geometry shape to be used as a Drop Zone.
226+ *
227+ * @method Phaser.GameObjects.Zone#setDropZone
228+ * @since 3.0.0
229+ *
230+ * @param {object } shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape.
231+ * @param {function } callback - A function that will return `true` if the given x/y coords it is sent are within the shape.
232+ *
233+ * @return {Phaser.GameObjects.Zone } This Game Object.
234+ */
117235 setDropZone : function ( shape , callback )
118236 {
119237 if ( shape === undefined )
@@ -133,14 +251,26 @@ var Zone = new Class({
133251 return this ;
134252 } ,
135253
254+ /**
255+ * A Zone does not render.
256+ *
257+ * @method Phaser.GameObjects.Zone#renderCanvas
258+ * @private
259+ * @since 3.0.0
260+ */
136261 renderCanvas : function ( )
137262 {
138- return ;
139263 } ,
140264
265+ /**
266+ * A Zone does not render.
267+ *
268+ * @method Phaser.GameObjects.Zone#renderWebGL
269+ * @private
270+ * @since 3.0.0
271+ */
141272 renderWebGL : function ( )
142273 {
143- return ;
144274 }
145275
146276} ) ;
0 commit comments