44* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License }
55*/
66
7+ /**
8+ * A Blitter Game Object.
9+ *
10+ * The Blitter Game Object is a special type of Container, that contains Blitter.Bob objects.
11+ * These objects can be thought of as just texture frames with a transform, and nothing more.
12+ * Bobs don't have any update methods, or the ability to have children, or any kind of special effects.
13+ * They are essentially just texture renderers, and the Blitter object creates and manages them.
14+ *
15+ * @class
16+ */
717Phaser . GameObject . Blitter = function ( state , parent )
818{
919 Phaser . GameObject . call ( this , state , 0 , 0 , null , null , parent ) ;
@@ -24,38 +34,60 @@ Phaser.GameObject.Blitter.prototype.preUpdate = function ()
2434 }
2535} ;
2636
27- Phaser . GameObject . Blitter . prototype . create = function ( frame , x , y , visible , index )
37+ Phaser . GameObject . Blitter . prototype . create = function ( x , y , key , frame , visible , index )
2838{
29- if ( x === undefined ) { x = 0 ; }
30- if ( y === undefined ) { y = 0 ; }
3139 if ( visible === undefined ) { visible = true ; }
3240 if ( index === undefined ) { index = 0 ; }
3341
34- var bob = new Phaser . GameObject . Blitter . Bob ( this , frame , x , y , visible ) ;
42+ var bob = new Phaser . GameObject . Blitter . Bob ( this , x , y , key , frame , visible ) ;
3543
36- this . children . addAt ( bob , index , true ) ;
44+ this . children . addAt ( bob , index , false ) ;
3745
3846 return bob ;
3947} ;
4048
41- Phaser . GameObject . Blitter . prototype . createMultiple = function ( quantity , frame , visible )
49+ Phaser . GameObject . Blitter . prototype . createFromCallback = function ( callback , quantity , key , frame , visible )
4250{
51+ var bobs = this . createMultiple ( quantity , key , frame , visible ) ;
52+
53+ for ( var i = 0 ; i < bobs . length ; i ++ )
54+ {
55+ var bob = bobs [ i ] ;
56+
57+ callback . call ( this , bob ) ;
58+ }
59+
60+ return bobs ;
61+ } ;
62+
63+ Phaser . GameObject . Blitter . prototype . createMultiple = function ( quantity , key , frame , visible )
64+ {
65+ if ( frame === undefined ) { frame = 0 ; }
4366 if ( visible === undefined ) { visible = true ; }
4467
68+ if ( ! Array . isArray ( key ) )
69+ {
70+ key = [ key ] ;
71+ }
72+
4573 if ( ! Array . isArray ( frame ) )
4674 {
4775 frame = [ frame ] ;
4876 }
4977
5078 var bobs = [ ] ;
79+ var _this = this ;
5180
52- for ( var f = 0 ; f < frame . length ; f ++ )
81+ key . forEach ( function ( singleKey )
5382 {
54- for ( var i = 0 ; i < quantity ; i ++ )
83+ frame . forEach ( function ( singleFrame )
5584 {
56- bobs . push ( this . create ( frame [ f ] , 0 , 0 , visible ) ) ;
57- }
58- }
85+ for ( var i = 0 ; i < quantity ; i ++ )
86+ {
87+ bobs . push ( _this . create ( 0 , 0 , singleKey , singleFrame , visible ) ) ;
88+ }
89+ } ) ;
90+ } ) ;
5991
6092 return bobs ;
6193} ;
0 commit comments