Skip to content

Commit 08c4ab0

Browse files
committed
Added internalCreateCallback and internalRemoveCallback to a Group
1 parent 847abb0 commit 08c4ab0

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/gameobjects/group/Group.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,28 @@ var Group = new Class({
214214
*/
215215
this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null);
216216

217+
/**
218+
* A function to be called when adding or creating group members.
219+
* For internal use only by a Group, or any class that extends it.
220+
*
221+
* @name Phaser.GameObjects.Group#internalCreateCallback
222+
* @type {?Phaser.Types.GameObjects.Group.GroupCallback}
223+
* @private
224+
* @since 3.22.0
225+
*/
226+
this.internalCreateCallback = null;
227+
228+
/**
229+
* A function to be called when removing group members.
230+
* For internal use only by a Group, or any class that extends it.
231+
*
232+
* @name Phaser.GameObjects.Group#internalRemoveCallback
233+
* @type {?Phaser.Types.GameObjects.Group.GroupCallback}
234+
* @private
235+
* @since 3.22.0
236+
*/
237+
this.internalRemoveCallback = null;
238+
217239
if (config)
218240
{
219241
this.createMultiple(config);
@@ -512,6 +534,11 @@ var Group = new Class({
512534

513535
this.children.set(child);
514536

537+
if (this.internalCreateCallback)
538+
{
539+
this.internalCreateCallback.call(this, child);
540+
}
541+
515542
if (this.createCallback)
516543
{
517544
this.createCallback.call(this, child);
@@ -586,6 +613,11 @@ var Group = new Class({
586613

587614
this.children.delete(child);
588615

616+
if (this.internalRemoveCallback)
617+
{
618+
this.internalRemoveCallback.call(this, child);
619+
}
620+
589621
if (this.removeCallback)
590622
{
591623
this.removeCallback.call(this, child);

0 commit comments

Comments
 (0)