1+ /**
2+ * @author Richard Davey <rich@phaser.io>
3+ * @copyright 2017 Photon Storm Ltd.
4+ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License }
5+ */
6+
17var Class = require ( '../utils/Class' ) ;
28var Components = require ( './components' ) ;
39var DataProxy = require ( './components/DataProxy' ) ;
410
5- /**
6- * The base GameObject class that all Game Objects extend.
7- *
8- * @class GameObject
9- *
10- * @param {Scene } scene - The Scene to which this Game Object belongs.
11- * @param {String } type - A textual representation of the Game Object.
12- */
1311var GameObject = new Class ( {
1412
1513 initialize :
1614
15+ /**
16+ * The base class that all Game Objects extend.
17+ * You don't create GameObjects directly and they cannot be added to the display list.
18+ * Instead, use them as the base for your own custom classes.
19+ *
20+ * @class GameObject
21+ * @namespace Phaser.GameObjects
22+ * @constructor
23+ *
24+ * @param {Phaser.Scene } scene - The Scene to which this Game Object belongs.
25+ * @param {string } type - A textual representation of the type of Game Object, i.e. `sprite`.
26+ */
1727 function GameObject ( scene , type )
1828 {
1929 /**
2030 * The Scene to which this Game Object belongs.
31+ * Game Objects can only belong to one Scene.
2132 *
22- * @property {Scene } scene
33+ * @property {Phaser. Scene } scene
2334 */
2435 this . scene = scene ;
2536
2637 /**
27- * A textual representation of this Game Object.
38+ * A textual representation of this Game Object, i.e. `sprite`.
39+ * Used internally by Phaser but is available for your own custom classes to populate.
2840 *
29- * @property {String } type
41+ * @property {string } type
3042 */
3143 this . type = type ;
3244
3345 /**
34- * The name of this Game Object. Blank by default and not populated by Phaser. Left for developers use.
46+ * The name of this Game Object.
47+ * Empty by default and never populated by Phaser, this is left for developers to use.
3548 *
36- * @property {String } [name='']
49+ * @property {string } [name='']
3750 */
3851 this . name = '' ;
3952
4053 /**
41- * The active state of this Game Object. A Game Object with an active state of `true` is processed by the UpdateList.
54+ * The active state of this Game Object.
55+ * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it.
4256 *
43- * @property {Boolean } [active=true]
57+ * @property {boolean } [active=true]
4458 */
4559 this . active = true ;
4660
4761 /**
48- * The Tab Index of this Game Object.
62+ * The Tab Index of the Game Object.
63+ * Reserved for future use by plugins and the Input Manager.
4964 *
50- * @property {Integer } [tabIndex=-1]
65+ * @property {integer } [tabIndex=-1]
5166 */
5267 this . tabIndex = - 1 ;
5368
5469 /**
55- * A proxy to the Data class. It allows you to store and query key/value paired information specific to this Game Object.
70+ * A proxy to the Data class.
71+ * It allows you to store, query and get key/value paired information specific to this Game Object.
5672 *
5773 * @property {DataProxy } data
5874 */
5975 this . data = new DataProxy ( scene , this ) ;
6076
61- /**
62- * The bitmask that determines if the Game Object will render or not.
63- * Structure: 0001 | 0010 | 0100 | 1000
64- * The components: Visible, Alpha, Transform and Texture set bits in this mask respectively
65- *
66- * @property {Integer } [renderMask=15]
67- * @private
68- */
69- this . renderMask = 15 ;
70-
7177 /**
7278 * The flags that the renderMask uses to determine if the Game Object will render or not.
79+ * Structure: 0001 | 0010 | 0100 | 1000
80+ * The components Visible, Alpha, Transform and Texture set the bits in this mask respectively
7381 *
74- * @property {Integer } [renderFlags=15]
82+ * @property {integer } [renderFlags=15]
7583 * @private
7684 */
7785 this . renderFlags = 15 ;
7886
7987 /**
8088 * A bitmask that controls if this Game Object is drawn by a Camera or not.
8189 *
82- * @property {Number } [cameraFilter=0]
90+ * @property {number } [cameraFilter=0]
8391 * @private
8492 */
8593 this . cameraFilter = 0 ;
@@ -105,9 +113,9 @@ var GameObject = new Class({
105113 /**
106114 * Sets the `active` property of this Game Object and returns this Game Object for further chaining.
107115 *
108- * @method GameObject# setActive
116+ * @method setActive
109117 *
110- * @param {Boolean } value - True if this Game Object should be set as active, false if not.
118+ * @param {boolean } value - True if this Game Object should be set as active, false if not.
111119 * @return {GameObject } This GameObject.
112120 */
113121 setActive : function ( value )
@@ -120,9 +128,9 @@ var GameObject = new Class({
120128 /**
121129 * Sets the `name` property of this Game Object and returns this Game Object for further chaining.
122130 *
123- * @method GameObject# setName
131+ * @method setName
124132 *
125- * @param {String } value - The name to be given to this Game Object.
133+ * @param {string } value - The name to be given to this Game Object.
126134 * @return {GameObject } This GameObject.
127135 */
128136 setName : function ( value )
@@ -135,10 +143,10 @@ var GameObject = new Class({
135143 /**
136144 * Pass this Game Object to the Input Manager to enable it for Input.
137145 *
138- * @method GameObject# setInteractive
146+ * @method setInteractive
139147 *
140- * @param {[type] } [shape] - A geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
141- * @param {Function } [callback] - A callback to be invoked when the Game Object is interacted with.
148+ * @param {any } [shape] - A geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
149+ * @param {function } [callback] - A callback to be invoked when the Game Object is interacted with.
142150 * @return {GameObject } This GameObject.
143151 */
144152 setInteractive : function ( shape , callback )
@@ -156,9 +164,9 @@ var GameObject = new Class({
156164 /**
157165 * Returns a JSON representation of the Game Object.
158166 *
159- * @method GameObject# toJSON
167+ * @method toJSON
160168 *
161- * @return {Object } A JSON representation of the Game Object.
169+ * @return {object } A JSON representation of the Game Object.
162170 */
163171 toJSON : function ( )
164172 {
@@ -168,13 +176,13 @@ var GameObject = new Class({
168176 /**
169177 * Compares the renderMask with the renderFlags to see if this Game Object will render or not.
170178 *
171- * @method GameObject# willRender
179+ * @method willRender
172180 *
173- * @return {Boolean } True if the Game Object should be rendered, otherwise false.
181+ * @return {boolean } True if the Game Object should be rendered, otherwise false.
174182 */
175183 willRender : function ( )
176184 {
177- return ( this . renderMask === this . renderFlags ) ;
185+ return ( GameObject . RENDER_MASK === this . renderFlags ) ;
178186 } ,
179187
180188 /**
@@ -184,7 +192,7 @@ var GameObject = new Class({
184192 * you don't plan to use it again later. If you do wish to use it later then look at using
185193 * the Game Object Pool class instead.
186194 *
187- * @method GameObject# destroy
195+ * @method destroy
188196 */
189197 destroy : function ( )
190198 {
@@ -208,4 +216,11 @@ var GameObject = new Class({
208216
209217} ) ;
210218
219+ /**
220+ * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not.
221+ *
222+ * @constant {integer} [RENDER_MASK=15]
223+ */
224+ GameObject . RENDER_MASK = 15 ;
225+
211226module . exports = GameObject ;
0 commit comments