You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @property {number} type - Internal Phaser Type value.
64
+
* @protected
64
65
*/
65
66
this.type=Phaser.GROUP;
66
67
67
68
/**
68
-
* @property {boolean} exists - Description.
69
+
* @property {boolean} exists - If exists is true the the Group is updated, otherwise it is skipped.
69
70
* @default
70
71
*/
71
72
this.exists=true;
72
-
73
-
/**
74
-
* @property {string} _sortIndex - Helper for sort.
75
-
* @private
76
-
* @default
77
-
*/
78
-
this._sortIndex='y';
79
73
80
74
};
81
75
82
76
Phaser.Group.prototype={
83
77
84
78
/**
85
-
* Description.
79
+
* Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object.
80
+
* The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control
81
+
* that then see the addAt method.
86
82
*
83
+
* @see Phaser.Group#create
84
+
* @see Phaser.Group#addAt
87
85
* @method Phaser.Group#add
88
-
* @param {Description} child - Description.
89
-
* @return {Description} Description.
86
+
* @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
87
+
* @return {*} The child that was added to the Group.
90
88
*/
91
89
add: function(child){
92
90
@@ -107,12 +105,13 @@ Phaser.Group.prototype = {
107
105
},
108
106
109
107
/**
110
-
* Description.
108
+
* Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object.
109
+
* The child is added to the Group at the location specified by the index value, this allows you to control child ordering.
111
110
*
112
111
* @method Phaser.Group#addAt
113
-
* @param {Description} child - Description.
114
-
* @param {Description} index - Description.
115
-
* @return {Description} Description.
112
+
* @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
113
+
* @param {number} index - The index within the Group to insert the child to.
114
+
* @return {*} The child that was added to the Group.
116
115
*/
117
116
addAt: function(child,index){
118
117
@@ -133,12 +132,12 @@ Phaser.Group.prototype = {
133
132
},
134
133
135
134
/**
136
-
* Description.
135
+
* Returns the child found at the given index within this Group.
137
136
*
138
137
* @method Phaser.Group#getAt
139
138
* @memberof Phaser.Group
140
-
* @param {Description} index - Description.
141
-
* @return {Description} Description.
139
+
* @param {number} index - The index to return the child from.
140
+
* @return {*} The child that was found at the given index.
142
141
*/
143
142
getAt: function(index){
144
143
@@ -147,15 +146,16 @@ Phaser.Group.prototype = {
147
146
},
148
147
149
148
/**
150
-
* Description.
149
+
* Automatically creates a new Phaser.Sprite object and adds it to the top of this Group.
150
+
* Useful if you don't need to create the Sprite instances before-hand.
151
151
*
152
152
* @method Phaser.Group#create
153
-
* @param {number} x - Description.
154
-
* @param {number} y - Description.
155
-
* @param {string} key - Description.
156
-
* @param {string} [frame] - Description.
157
-
* @param {boolean} [exists] - Description.
158
-
* @return {Description} Description.
153
+
* @param {number} x - The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point.
154
+
* @param {number} y - The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point.
155
+
* @param {string} key - The Game.cache key of the image that this Sprite will use.
156
+
* @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here.
157
+
* @param {boolean} [exists] - The default exists state of the Sprite.
158
+
* @return {Phaser.Sprite} The child that was created.
159
159
*/
160
160
create: function(x,y,key,frame,exists){
161
161
@@ -178,12 +178,12 @@ Phaser.Group.prototype = {
178
178
},
179
179
180
180
/**
181
-
* Description.
181
+
* Swaps the position of two children in this Group.
182
182
*
183
183
* @method Phaser.Group#swap
184
-
* @param {Description} child1 - Description.
185
-
* @param {Description} child2 - Description.
186
-
* @return {boolean} Description.
184
+
* @param {*} child1 - The first child to swap.
185
+
* @param {*} child2 - The second child to swap.
186
+
* @return {boolean} True if the swap was successful, otherwise false.
187
187
*/
188
188
swap: function(child1,child2){
189
189
@@ -306,11 +306,11 @@ Phaser.Group.prototype = {
306
306
},
307
307
308
308
/**
309
-
* Description.
309
+
* Brings the given child to the top of this Group so it renders above all other children.
310
310
*
311
311
* @method Phaser.Group#bringToTop
312
-
* @param {Description} child - Description.
313
-
* @return {Description} Description.
312
+
* @param {*} child - The child to bring to the top of this Group.
313
+
* @return {*} The child that was moved.
314
314
*/
315
315
bringToTop: function(child){
316
316
@@ -325,11 +325,11 @@ Phaser.Group.prototype = {
325
325
},
326
326
327
327
/**
328
-
* Description.
328
+
* Get the index position of the given child in this Group.
329
329
*
330
330
* @method Phaser.Group#getIndex
331
-
* @param {Description} child - Description.
332
-
* @return {Description} Description.
331
+
* @param {*} child - The child to get the index for.
332
+
* @return {number} The index of the child or -1 if it's not a member of this Group.
333
333
*/
334
334
getIndex: function(child){
335
335
@@ -338,11 +338,11 @@ Phaser.Group.prototype = {
338
338
},
339
339
340
340
/**
341
-
* Description.
341
+
* Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group.
342
342
*
343
343
* @method Phaser.Group#replace
344
-
* @param {Description} oldChild - Description.
345
-
* @param {Description} newChild - Description.
344
+
* @param {*} oldChild - The child in this Group that will be replaced.
345
+
* @param {*} newChild - The child to be inserted into this group.
346
346
*/
347
347
replace: function(oldChild,newChild){
348
348
@@ -369,14 +369,13 @@ Phaser.Group.prototype = {
369
369
},
370
370
371
371
/**
372
-
* Description.
372
+
* Sets the given property to the given value on the child. The operation controls the assignment of the value.
373
373
*
374
374
* @method Phaser.Group#setProperty
375
-
* @param {Description} child - Description.
376
-
* @param {array} key - An array of values that will be set.
377
-
* @param {Description} value - Description.
378
-
* @param {Description} operation - Description.
379
-
* @return {number} An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2). (TODO)
375
+
* @param {*} child - The child to set the property value on.
376
+
* @param {array} key - An array of strings that make up the property that will be set.
377
+
* @param {*} value - The value that will be set.
378
+
* @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
380
379
*/
381
380
setProperty: function(child,key,value,operation){
382
381
@@ -432,14 +431,15 @@ Phaser.Group.prototype = {
432
431
},
433
432
434
433
/**
435
-
* Description.
434
+
* This function allows you to quickly set the same property across all children of this Group to a new value.
435
+
* The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.
* @param {string} key - The property, as a string, to be set. For example: 'body.velocity.x'
439
+
* @param {*} value - The value that will be set.
440
+
* @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated.
441
+
* @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated.
442
+
* @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
* Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run.
640
+
* You can add as many parameters as you like, which will all be passed to the callback along with the child.
641
+
* For example: Group.forEachAlive(causeDamage, this, 500)
* @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
645
+
* @param {Object} callbackContext - The context in which the function should be called (usually 'this').
643
646
*/
644
647
forEachAlive: function(callback,callbackContext){
645
648
@@ -667,11 +670,13 @@ Phaser.Group.prototype = {
667
670
},
668
671
669
672
/**
670
-
* Description.
673
+
* Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run.
674
+
* You can add as many parameters as you like, which will all be passed to the callback along with the child.
675
+
* For example: Group.forEachDead(bringToLife, this)
* @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
679
+
* @param {Object} callbackContext - The context in which the function should be called (usually 'this').
675
680
*/
676
681
forEachDead: function(callback,callbackContext){
677
682
@@ -698,10 +703,10 @@ Phaser.Group.prototype = {
698
703
},
699
704
700
705
/**
701
-
* Call this function to retrieve the first object with exists == (the given state) in the group.
706
+
* Call this function to retrieve the first object with exists == (the given state) in the Group.
702
707
*
703
708
* @method Phaser.Group#getFirstExists
704
-
* @param {Description} state - Description.
709
+
* @param {boolean} state - True or false.
705
710
* @return {Any} The first child, or null if none found.
706
711
*/
707
712
getFirstExists: function(state){
@@ -733,7 +738,7 @@ Phaser.Group.prototype = {
733
738
734
739
/**
735
740
* Call this function to retrieve the first object with alive == true in the group.
736
-
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
741
+
* This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.
737
742
*
738
743
* @method Phaser.Group#getFirstAlive
739
744
* @return {Any} The first alive child, or null if none found.
@@ -762,7 +767,7 @@ Phaser.Group.prototype = {
762
767
763
768
/**
764
769
* Call this function to retrieve the first object with alive == false in the group.
765
-
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
770
+
* This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.
766
771
*
767
772
* @method Phaser.Group#getFirstDead
768
773
* @return {Any} The first dead child, or null if none found.
@@ -872,10 +877,10 @@ Phaser.Group.prototype = {
872
877
},
873
878
874
879
/**
875
-
* Description.
880
+
* Removes the given child from this Group and sets its group property to null.
876
881
*
877
882
* @method Phaser.Group#remove
878
-
* @param {Description} child - Description.
883
+
* @param {Any} child - The child to remove.
879
884
*/
880
885
remove: function(child){
881
886
@@ -886,7 +891,8 @@ Phaser.Group.prototype = {
886
891
},
887
892
888
893
/**
889
-
* Description.
894
+
* Removes all children from this Group, setting all group properties to null.
895
+
* The Group container remains on the display list.
890
896
*
891
897
* @method Phaser.Group#removeAll
892
898
*/
@@ -910,11 +916,11 @@ Phaser.Group.prototype = {
910
916
},
911
917
912
918
/**
913
-
* Description.
919
+
* Removes all children from this Group whos index falls beteen the given startIndex and endIndex values.
914
920
*
915
921
* @method Phaser.Group#removeBetween
916
-
* @param {Description} startIndex - Description.
917
-
* @param {Description} endIndex - Description.
922
+
* @param {number} startIndex - The index to start removing children from.
923
+
* @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group.
918
924
*/
919
925
removeBetween: function(startIndex,endIndex){
920
926
@@ -938,7 +944,7 @@ Phaser.Group.prototype = {
938
944
},
939
945
940
946
/**
941
-
* Description.
947
+
* Destroys this Group. Removes all children, then removes the container from the display list and nulls references.
942
948
*
943
949
* @method Phaser.Group#destroy
944
950
*/
@@ -957,9 +963,10 @@ Phaser.Group.prototype = {
957
963
},
958
964
959
965
/**
960
-
* Description.
966
+
* Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging.
961
967
*
962
968
* @method Phaser.Group#dump
969
+
* @param {boolean} [full=false] - If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container.
963
970
*/
964
971
dump: function(full){
965
972
@@ -1047,7 +1054,6 @@ Phaser.Group.prototype = {
1047
1054
1048
1055
};
1049
1056
1050
-
1051
1057
/**
1052
1058
* @name Phaser.Group#length
1053
1059
* @property {number} length - The number of children in this Group.
0 commit comments