@@ -9,13 +9,26 @@ var Group = new Class({
99
1010 initialize :
1111
12+ // children can be either an array of children, or a config object
13+ // config can be either a config object, or undefined if passed as the children argument instead
1214 function Group ( scene , children , config )
1315 {
16+ if ( config === undefined && ! Array . isArray ( children ) && typeof children === 'object' )
17+ {
18+ config = children ;
19+ children = null ;
20+ }
21+
1422 this . scene = scene ;
1523
1624 this . children = new Set ( children ) ;
1725
18- this . classType = Sprite ;
26+ this . isParent = true ;
27+
28+ this . classType = GetValue ( config , 'classType' , Sprite ) ;
29+
30+ this . createCallback = GetValue ( config , 'createCallback' , null ) ;
31+ this . removeCallback = GetValue ( config , 'removeCallback' , null ) ;
1932
2033 if ( config )
2134 {
@@ -43,6 +56,11 @@ var Group = new Class({
4356 {
4457 this . children . set ( child ) ;
4558
59+ if ( this . createCallback )
60+ {
61+ this . createCallback . call ( this , child ) ;
62+ }
63+
4664 return this ;
4765 } ,
4866
@@ -52,7 +70,7 @@ var Group = new Class({
5270 {
5371 for ( var i = 0 ; i < children . length ; i ++ )
5472 {
55- this . children . set ( children [ i ] ) ;
73+ this . add ( children [ i ] ) ;
5674 }
5775 }
5876
@@ -74,7 +92,7 @@ var Group = new Class({
7492
7593 child . visible = visible ;
7694
77- this . children . set ( child ) ;
95+ this . add ( child ) ;
7896
7997 return child ;
8098 } ,
@@ -116,6 +134,8 @@ var Group = new Class({
116134 var quantity = GetValue ( options , 'frameQuantity' , 1 ) ;
117135 var max = GetValue ( options , 'max' , 0 ) ;
118136
137+ // If a grid is set we use that to override the quantity?
138+
119139 var range = Range ( key , frame , {
120140 max : max ,
121141 qty : quantity ,
@@ -207,6 +227,11 @@ var Group = new Class({
207227 return this ;
208228 } ,
209229
230+ contains : function ( child )
231+ {
232+ return this . children . contains ( child ) ;
233+ } ,
234+
210235 getChildren : function ( )
211236 {
212237 return this . children . entries ;
0 commit comments