1- Phaser . Group = function ( game , parent , name ) {
1+ Phaser . Group = function ( game , parent , name , useStage ) {
22
33 parent = parent || null ;
44
5+ if ( typeof useStage == 'undefined' )
6+ {
7+ useStage = false ;
8+ }
9+
510 this . game = game ;
611 this . name = name || 'group' ;
712
8- this . _container = new PIXI . DisplayObjectContainer ( ) ;
9- this . _container . name = this . name ;
10-
11- if ( parent )
13+ if ( useStage )
14+ {
15+ this . _container = this . game . stage . _stage ;
16+ }
17+ else
1218 {
13- if ( parent instanceof Phaser . Group )
19+ this . _container = new PIXI . DisplayObjectContainer ( ) ;
20+ this . _container . name = this . name ;
21+
22+ if ( parent )
1423 {
15- parent . _container . addChild ( this . _container ) ;
24+ if ( parent instanceof Phaser . Group )
25+ {
26+ parent . _container . addChild ( this . _container ) ;
27+ }
28+ else
29+ {
30+ parent . addChild ( this . _container ) ;
31+ }
1632 }
1733 else
1834 {
19- parent . addChild ( this . _container ) ;
35+ this . game . stage . _stage . addChild ( this . _container ) ;
2036 }
2137 }
22- else
23- {
24- this . game . world . add ( this . _container ) ;
25- }
2638
2739 this . exists = true ;
2840
@@ -274,13 +286,13 @@ Phaser.Group.prototype = {
274286 sortHandler : function ( obj1 , obj2 ) {
275287
276288 /*
277- if(!obj1 || !obj2) {
289+ if (!obj1 || !obj2) {
278290 //console.log('null objects in sort', obj1, obj2);
279291 return 0;
280292 }
281- if(obj1[this._sortIndex] < obj2[this._sortIndex]) {
293+ if (obj1[this._sortIndex] < obj2[this._sortIndex]) {
282294 return this._sortOrder;
283- } else if(obj1[this._sortIndex] > obj2[this._sortIndex]) {
295+ } else if (obj1[this._sortIndex] > obj2[this._sortIndex]) {
284296 return -this._sortOrder;
285297 }
286298 return 0;
@@ -788,10 +800,8 @@ Object.defineProperty(Phaser.Group.prototype, "x", {
788800
789801 set : function ( value ) {
790802 this . _container . position . x = value ;
791- } ,
803+ }
792804
793- enumerable : true ,
794- configurable : true
795805} ) ;
796806
797807Object . defineProperty ( Phaser . Group . prototype , "y" , {
@@ -802,10 +812,8 @@ Object.defineProperty(Phaser.Group.prototype, "y", {
802812
803813 set : function ( value ) {
804814 this . _container . position . y = value ;
805- } ,
815+ }
806816
807- enumerable : true ,
808- configurable : true
809817} ) ;
810818
811819Object . defineProperty ( Phaser . Group . prototype , "angle" , {
@@ -816,10 +824,8 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
816824
817825 set : function ( value ) {
818826 this . _container . rotation = Phaser . Math . degToRad ( value ) ;
819- } ,
827+ }
820828
821- enumerable : true ,
822- configurable : true
823829} ) ;
824830
825831Object . defineProperty ( Phaser . Group . prototype , "rotation" , {
@@ -830,10 +836,8 @@ Object.defineProperty(Phaser.Group.prototype, "rotation", {
830836
831837 set : function ( value ) {
832838 this . _container . rotation = value ;
833- } ,
839+ }
834840
835- enumerable : true ,
836- configurable : true
837841} ) ;
838842
839843Object . defineProperty ( Phaser . Group . prototype , "visible" , {
@@ -844,8 +848,6 @@ Object.defineProperty(Phaser.Group.prototype, "visible", {
844848
845849 set : function ( value ) {
846850 this . _container . visible = value ;
847- } ,
851+ }
848852
849- enumerable : true ,
850- configurable : true
851853} ) ;
0 commit comments