@@ -32,6 +32,7 @@ Phaser.Group.prototype = {
3232 if ( child . group !== this )
3333 {
3434 child . group = this ;
35+ child . events . onAddedToGroup . dispatch ( child , this ) ;
3536 this . _container . addChild ( child ) ;
3637 }
3738
@@ -44,6 +45,7 @@ Phaser.Group.prototype = {
4445 if ( child . group !== this )
4546 {
4647 child . group = this ;
48+ child . events . onAddedToGroup . dispatch ( child , this ) ;
4749 this . _container . addChildAt ( child , index ) ;
4850 }
4951
@@ -61,6 +63,7 @@ Phaser.Group.prototype = {
6163
6264 var child = new Phaser . Sprite ( this . game , x , y , key , frame ) ;
6365 child . group = this ;
66+ child . events . onAddedToGroup . dispatch ( child , this ) ;
6467 this . _container . addChild ( child ) ;
6568 return child ;
6669
@@ -186,11 +189,13 @@ Phaser.Group.prototype = {
186189 {
187190 if ( newChild . parent != undefined )
188191 {
192+ newChild . events . onRemovedFromGroup . dispatch ( newChild , this ) ;
189193 newChild . parent . removeChild ( newChild ) ;
190194 }
191195
192196 this . _container . removeChild ( oldChild ) ;
193197 this . _container . addChildAt ( newChild , index ) ;
198+ newChild . events . onAddedToGroup . dispatch ( newChild , this ) ;
194199 }
195200
196201 } ,
@@ -600,6 +605,7 @@ Phaser.Group.prototype = {
600605
601606 remove : function ( child ) {
602607
608+ child . events . onRemovedFromGroup . dispatch ( child , this ) ;
603609 this . _container . removeChild ( child ) ;
604610
605611 } ,
@@ -608,6 +614,7 @@ Phaser.Group.prototype = {
608614
609615 do
610616 {
617+ this . _container . children [ 0 ] . events . onRemovedFromGroup . dispatch ( this . _container . children [ 0 ] , this ) ;
611618 this . _container . removeChild ( this . _container . children [ 0 ] ) ;
612619 }
613620 while ( this . _container . children . length > 0 ) ;
@@ -624,6 +631,7 @@ Phaser.Group.prototype = {
624631 for ( var i = startIndex ; i < endIndex ; i ++ )
625632 {
626633 var child = this . _container . children [ i ] ;
634+ child . events . onRemovedFromGroup . dispatch ( child , this ) ;
627635 this . _container . removeChild ( child ) ;
628636 }
629637
0 commit comments