1010*
1111* @class
1212*/
13- Phaser . Component . Data = function ( gameObject )
13+ Phaser . Component . Data = function ( parent )
1414{
15- this . gameObject = gameObject ;
15+ this . parent = parent ;
1616
1717 this . list = { } ;
1818
@@ -74,7 +74,7 @@ Phaser.Component.Data.prototype = {
7474 {
7575 listener = this . _beforeCallbacks [ key ] ;
7676
77- result = listener . callback . call ( listener . scope , this . gameObject , key , data ) ;
77+ result = listener . callback . call ( listener . scope , this . parent , key , data ) ;
7878
7979 if ( result !== undefined )
8080 {
@@ -89,7 +89,7 @@ Phaser.Component.Data.prototype = {
8989 {
9090 listener = this . _afterCallbacks [ key ] ;
9191
92- result = listener . callback . call ( listener . scope , this . gameObject , key , data ) ;
92+ result = listener . callback . call ( listener . scope , this . parent , key , data ) ;
9393
9494 if ( result !== undefined )
9595 {
@@ -136,7 +136,7 @@ Phaser.Component.Data.prototype = {
136136 */
137137 each : function ( callback , scope )
138138 {
139- var args = [ this . gameObject , null , undefined ] ;
139+ var args = [ this . parent , null , undefined ] ;
140140
141141 for ( var i = 1 ; i < arguments . length ; i ++ )
142142 {
@@ -152,14 +152,18 @@ Phaser.Component.Data.prototype = {
152152 }
153153 } ,
154154
155- merge : function ( data )
155+ merge : function ( data , overwrite )
156156 {
157- // Merge data from another component into this one
158- } ,
157+ if ( overwrite === undefined ) { overwrite = true ; }
159158
160- clone : function ( data )
161- {
162- // Export this Data component
159+ // Merge data from another component into this one
160+ for ( var key in data )
161+ {
162+ if ( overwrite || ( ! overwrite && ! this . list . hasOwnProperty ( key ) ) )
163+ {
164+ this . list [ key ] = data ;
165+ }
166+ }
163167 } ,
164168
165169 remove : function ( key )
0 commit comments