22var Class = require ( '../../utils/Class' ) ;
33var Set = require ( '../../structs/Set' ) ;
44var GetObjectValue = require ( '../../utils/object/GetObjectValue' ) ;
5+ var Range = require ( '../../utils/array/Range' ) ;
56var Actions = require ( '../../actions/' ) ;
67var Sprite = require ( '../sprite/Sprite' ) ;
78
@@ -84,12 +85,7 @@ var Layer = new Class({
8485 * It will then create 20 'balls' of frame 0, 20 with frame 1 and 20 with frame 2.
8586 * In total it will have created 120 sprites.
8687 *
87- * By default the Sprites will have their `exists` property set to `false`, and they will be
88- * positioned at 0x0, relative to the `Group.x / y` values.
89- *
90- * If `Group.enableBody` is set, then a physics body will be created on the objects, so long as one does not already exist.
91- *
92- * If `Group.inputEnableChildren` is set, then an Input Handler will be created on the objects, so long as one does not already exist.
88+ * By default the Sprites will be positioned at 0x0.
9389 *
9490 * @method Phaser.Group#createMultiple
9591 * @param {integer } quantity - The number of Sprites to create.
@@ -98,10 +94,9 @@ var Layer = new Class({
9894 * @param {boolean } [exists=false] - The default exists state of the Sprite.
9995 * @return {array } An array containing all of the Sprites that were created.
10096 */
101- createMultiple : function ( quantity , key , frame , options )
97+ createMultiple : function ( key , frame , options )
10298 {
10399 if ( frame === undefined ) { frame = null ; }
104- // if (options === undefined) { options = {}; }
105100
106101 var visible = GetObjectValue ( options , 'visible' , true ) ;
107102
@@ -115,36 +110,47 @@ var Layer = new Class({
115110 frame = [ frame ] ;
116111 }
117112
118- var _this = this ;
113+ // Build an array of key frame pairs to loop through
114+
115+ var repeat = GetObjectValue ( options , 'repeat' , 0 ) ;
116+ var randomKey = GetObjectValue ( options , 'randomKey' , false ) ;
117+ var randomFrame = GetObjectValue ( options , 'randomFrame' , false ) ;
118+ var yoyo = GetObjectValue ( options , 'yoyo' , false ) ;
119+ var quantity = GetObjectValue ( options , 'quantity' , 1 ) ;
120+ var max = GetObjectValue ( options , 'max' , 0 ) ;
121+
119122 var entries = [ ] ;
120123
121- key . forEach ( function ( singleKey )
122- {
123- frame . forEach ( function ( singleFrame )
124- {
125- for ( var i = 0 ; i < quantity ; i ++ )
126- {
127- entries . push ( _this . create ( 0 , 0 , singleKey , singleFrame , visible ) ) ;
128- }
129- } ) ;
124+ var range = Range ( key , frame , {
125+ max : max ,
126+ qty : quantity ,
127+ random : randomKey ,
128+ randomB : randomFrame ,
129+ repeat : repeat ,
130+ yoyo : yoyo
130131 } ) ;
131132
133+ for ( var i = 0 ; i < range . length ; i ++ )
134+ {
135+ entries . push ( this . create ( 0 , 0 , range [ i ] . a , range [ i ] . b , visible ) ) ;
136+ }
137+
132138 // Post-creation options:
133139
134- var x = GetObjectValue ( options , 'x' , 0 ) ;
135- var y = GetObjectValue ( options , 'y' , 0 ) ;
136- var stepX = GetObjectValue ( options , 'stepX' , 0 ) ;
137- var stepY = GetObjectValue ( options , 'stepY' , 0 ) ;
140+ var x = GetObjectValue ( options , 'setXY. x' , 0 ) ;
141+ var y = GetObjectValue ( options , 'setXY. y' , 0 ) ;
142+ var stepX = GetObjectValue ( options , 'setXY. stepX' , 0 ) ;
143+ var stepY = GetObjectValue ( options , 'setXY. stepY' , 0 ) ;
138144
139145 this . setXY ( x , y , stepX , stepY ) ;
140146
141- var rotation = GetObjectValue ( options , 'rotation ' , 0 ) ;
142- var stepRotation = GetObjectValue ( options , 'stepRotation ' , 0 ) ;
147+ var rotation = GetObjectValue ( options , 'setRotation.value ' , 0 ) ;
148+ var stepRotation = GetObjectValue ( options , 'setRotation.step ' , 0 ) ;
143149
144150 this . setRotation ( rotation , stepRotation ) ;
145151
146- var alpha = GetObjectValue ( options , 'alpha ' , 1 ) ;
147- var stepAlpha = GetObjectValue ( options , 'stepAlpha ' , 0 ) ;
152+ var alpha = GetObjectValue ( options , 'setAlpha.value ' , 1 ) ;
153+ var stepAlpha = GetObjectValue ( options , 'setAlpha.step ' , 0 ) ;
148154
149155 this . setAlpha ( alpha , stepAlpha ) ;
150156
0 commit comments