@@ -385,19 +385,20 @@ var TextureManager = new Class({
385385 * @param {string } key - The unique string-based key of the Texture.
386386 * @param {HTMLImageElement } source - The source Image element.
387387 * @param {object } data - The Texture Atlas data.
388+ * @param {HTMLImageElement } [dataSource] - An optional data Image element.
388389 *
389390 * @return {?Phaser.Textures.Texture } The Texture that was created, or `null` if the key is already in use.
390391 */
391- addAtlas : function ( key , source , data )
392+ addAtlas : function ( key , source , data , dataSource )
392393 {
393394 // New Texture Packer format?
394395 if ( Array . isArray ( data . textures ) || Array . isArray ( data . frames ) )
395396 {
396- return this . addAtlasJSONArray ( key , source , data ) ;
397+ return this . addAtlasJSONArray ( key , source , data , dataSource ) ;
397398 }
398399 else
399400 {
400- return this . addAtlasJSONHash ( key , source , data ) ;
401+ return this . addAtlasJSONHash ( key , source , data , dataSource ) ;
401402 }
402403 } ,
403404
@@ -412,17 +413,19 @@ var TextureManager = new Class({
412413 * @param {string } key - The unique string-based key of the Texture.
413414 * @param {(HTMLImageElement|HTMLImageElement[]) } source - The source Image element/s.
414415 * @param {(object|object[]) } data - The Texture Atlas data/s.
416+ * @param {HTMLImageElement } [dataSource] - An optional data Image element.
415417 *
416418 * @return {?Phaser.Textures.Texture } The Texture that was created, or `null` if the key is already in use.
417419 */
418- addAtlasJSONArray : function ( key , source , data )
420+ addAtlasJSONArray : function ( key , source , data , dataSource )
419421 {
420422 var texture = null ;
421423
422424 if ( this . checkKey ( key ) )
423425 {
424426 texture = this . create ( key , source ) ;
425427
428+ // Multi-Atlas?
426429 if ( Array . isArray ( data ) )
427430 {
428431 var singleAtlasFile = ( data . length === 1 ) ; // multi-pack with one atlas file for all images
@@ -440,6 +443,11 @@ var TextureManager = new Class({
440443 Parser . JSONArray ( texture , 0 , data ) ;
441444 }
442445
446+ if ( dataSource )
447+ {
448+ texture . setDataSource ( dataSource ) ;
449+ }
450+
443451 this . emit ( 'addtexture' , key , texture ) ;
444452 }
445453
@@ -457,10 +465,11 @@ var TextureManager = new Class({
457465 * @param {string } key - The unique string-based key of the Texture.
458466 * @param {HTMLImageElement } source - The source Image element.
459467 * @param {object } data - The Texture Atlas data.
468+ * @param {HTMLImageElement } [dataSource] - An optional data Image element.
460469 *
461470 * @return {?Phaser.Textures.Texture } The Texture that was created, or `null` if the key is already in use.
462471 */
463- addAtlasJSONHash : function ( key , source , data )
472+ addAtlasJSONHash : function ( key , source , data , dataSource )
464473 {
465474 var texture = null ;
466475
@@ -480,6 +489,46 @@ var TextureManager = new Class({
480489 Parser . JSONHash ( texture , 0 , data ) ;
481490 }
482491
492+ if ( dataSource )
493+ {
494+ texture . setDataSource ( dataSource ) ;
495+ }
496+
497+ this . emit ( 'addtexture' , key , texture ) ;
498+ }
499+
500+ return texture ;
501+ } ,
502+
503+ /**
504+ * Adds a Texture Atlas to this Texture Manager, where the atlas data is given
505+ * in the XML format.
506+ *
507+ * @method Phaser.Textures.TextureManager#addAtlasXML
508+ * @since 3.7.0
509+ *
510+ * @param {string } key - The unique string-based key of the Texture.
511+ * @param {HTMLImageElement } source - The source Image element.
512+ * @param {object } data - The Texture Atlas XML data.
513+ * @param {HTMLImageElement } [dataSource] - An optional data Image element.
514+ *
515+ * @return {?Phaser.Textures.Texture } The Texture that was created, or `null` if the key is already in use.
516+ */
517+ addAtlasXML : function ( key , source , data , dataSource )
518+ {
519+ var texture = null ;
520+
521+ if ( this . checkKey ( key ) )
522+ {
523+ texture = this . create ( key , source ) ;
524+
525+ Parser . AtlasXML ( texture , 0 , data ) ;
526+
527+ if ( dataSource )
528+ {
529+ texture . setDataSource ( dataSource ) ;
530+ }
531+
483532 this . emit ( 'addtexture' , key , texture ) ;
484533 }
485534
@@ -496,10 +545,11 @@ var TextureManager = new Class({
496545 * @param {string } key - The unique string-based key of the Texture.
497546 * @param {HTMLImageElement } source - The source Image element.
498547 * @param {object } data - The Texture Atlas data.
548+ * @param {HTMLImageElement } [dataSource] - An optional data Image element.
499549 *
500550 * @return {?Phaser.Textures.Texture } The Texture that was created, or `null` if the key is already in use.
501551 */
502- addUnityAtlas : function ( key , source , data )
552+ addUnityAtlas : function ( key , source , data , dataSource )
503553 {
504554 var texture = null ;
505555
@@ -509,6 +559,11 @@ var TextureManager = new Class({
509559
510560 Parser . UnityYAML ( texture , 0 , data ) ;
511561
562+ if ( dataSource )
563+ {
564+ texture . setDataSource ( dataSource ) ;
565+ }
566+
512567 this . emit ( 'addtexture' , key , texture ) ;
513568 }
514569
@@ -625,35 +680,6 @@ var TextureManager = new Class({
625680 }
626681 } ,
627682
628- /**
629- * Adds a Texture Atlas to this Texture Manager, where the atlas data is given
630- * in the XML format.
631- *
632- * @method Phaser.Textures.TextureManager#addAtlasXML
633- * @since 3.7.0
634- *
635- * @param {string } key - The unique string-based key of the Texture.
636- * @param {HTMLImageElement } source - The source Image element.
637- * @param {object } data - The Texture Atlas XML data.
638- *
639- * @return {?Phaser.Textures.Texture } The Texture that was created, or `null` if the key is already in use.
640- */
641- addAtlasXML : function ( key , source , data )
642- {
643- var texture = null ;
644-
645- if ( this . checkKey ( key ) )
646- {
647- texture = this . create ( key , source ) ;
648-
649- Parser . AtlasXML ( texture , 0 , data ) ;
650-
651- this . emit ( 'addtexture' , key , texture ) ;
652- }
653-
654- return texture ;
655- } ,
656-
657683 /**
658684 * Creates a new Texture using the given source and dimensions.
659685 *
0 commit comments