@@ -10,6 +10,8 @@ var Class = require('../utils/Class');
1010var Color = require ( '../display/color/Color' ) ;
1111var CONST = require ( '../const' ) ;
1212var EventEmitter = require ( 'eventemitter3' ) ;
13+ var Events = require ( './events' ) ;
14+ var GameEvents = require ( '../core/events' ) ;
1315var GenerateTexture = require ( '../create/GenerateTexture' ) ;
1416var GetValue = require ( '../utils/object/GetValue' ) ;
1517var Parser = require ( './parsers' ) ;
@@ -109,7 +111,7 @@ var TextureManager = new Class({
109111 */
110112 this . _pending = 0 ;
111113
112- game . events . once ( 'boot' , this . boot , this ) ;
114+ game . events . once ( GameEvents . BOOT , this . boot , this ) ;
113115 } ,
114116
115117 /**
@@ -129,7 +131,7 @@ var TextureManager = new Class({
129131 this . addBase64 ( '__DEFAULT' , this . game . config . defaultImage ) ;
130132 this . addBase64 ( '__MISSING' , this . game . config . missingImage ) ;
131133
132- this . game . events . once ( 'destroy' , this . destroy , this ) ;
134+ this . game . events . once ( GameEvents . DESTROY , this . destroy , this ) ;
133135 } ,
134136
135137 /**
@@ -148,7 +150,7 @@ var TextureManager = new Class({
148150 this . off ( 'onload' ) ;
149151 this . off ( 'onerror' ) ;
150152
151- this . game . events . emit ( 'texturesready' ) ;
153+ this . game . events . emit ( GameEvents . TEXTURES_READY ) ;
152154 }
153155 } ,
154156
@@ -186,6 +188,7 @@ var TextureManager = new Class({
186188 * step when clearing down to avoid this.
187189 *
188190 * @method Phaser.Textures.TextureManager#remove
191+ * @fires Phaser.Textures.Events#REMOVE
189192 * @since 3.7.0
190193 *
191194 * @param {(string|Phaser.Textures.Texture) } key - The key of the Texture to remove, or a reference to it.
@@ -214,7 +217,7 @@ var TextureManager = new Class({
214217
215218 key . destroy ( ) ;
216219
217- this . emit ( 'removetexture' , key . key ) ;
220+ this . emit ( Events . REMOVE , key . key ) ;
218221 }
219222
220223 return this ;
@@ -224,6 +227,9 @@ var TextureManager = new Class({
224227 * Adds a new Texture to the Texture Manager created from the given Base64 encoded data.
225228 *
226229 * @method Phaser.Textures.TextureManager#addBase64
230+ * @fires Phaser.Textures.Events#ADD
231+ * @fires Phaser.Textures.Events#ERROR
232+ * @fires Phaser.Textures.Events#LOAD
227233 * @since 3.0.0
228234 *
229235 * @param {string } key - The unique string-based key of the Texture.
@@ -241,7 +247,7 @@ var TextureManager = new Class({
241247
242248 image . onerror = function ( )
243249 {
244- _this . emit ( 'onerror' , key ) ;
250+ _this . emit ( Events . ERROR , key ) ;
245251 } ;
246252
247253 image . onload = function ( )
@@ -250,9 +256,9 @@ var TextureManager = new Class({
250256
251257 Parser . Image ( texture , 0 ) ;
252258
253- _this . emit ( 'addtexture' , key , texture ) ;
259+ _this . emit ( Events . ADD , key , texture ) ;
254260
255- _this . emit ( 'onload' , key , texture ) ;
261+ _this . emit ( Events . LOAD , key , texture ) ;
256262 } ;
257263
258264 image . src = data ;
@@ -316,6 +322,7 @@ var TextureManager = new Class({
316322 * Adds a new Texture to the Texture Manager created from the given Image element.
317323 *
318324 * @method Phaser.Textures.TextureManager#addImage
325+ * @fires Phaser.Textures.Events#ADD
319326 * @since 3.0.0
320327 *
321328 * @param {string } key - The unique string-based key of the Texture.
@@ -339,7 +346,7 @@ var TextureManager = new Class({
339346 texture . setDataSource ( dataSource ) ;
340347 }
341348
342- this . emit ( 'addtexture' , key , texture ) ;
349+ this . emit ( Events . ADD , key , texture ) ;
343350 }
344351
345352 return texture ;
@@ -350,6 +357,7 @@ var TextureManager = new Class({
350357 * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites.
351358 *
352359 * @method Phaser.Textures.TextureManager#addRenderTexture
360+ * @fires Phaser.Textures.Events#ADD
353361 * @since 3.12.0
354362 *
355363 * @param {string } key - The unique string-based key of the Texture.
@@ -367,7 +375,7 @@ var TextureManager = new Class({
367375
368376 texture . add ( '__BASE' , 0 , 0 , 0 , renderTexture . width , renderTexture . height ) ;
369377
370- this . emit ( 'addtexture' , key , texture ) ;
378+ this . emit ( Events . ADD , key , texture ) ;
371379 }
372380
373381 return texture ;
@@ -439,6 +447,7 @@ var TextureManager = new Class({
439447 * and adds it to this Texture Manager, unless `skipCache` is true.
440448 *
441449 * @method Phaser.Textures.TextureManager#addCanvas
450+ * @fires Phaser.Textures.Events#ADD
442451 * @since 3.0.0
443452 *
444453 * @param {string } key - The unique string-based key of the Texture.
@@ -463,7 +472,7 @@ var TextureManager = new Class({
463472
464473 this . list [ key ] = texture ;
465474
466- this . emit ( 'addtexture' , key , texture ) ;
475+ this . emit ( Events . ADD , key , texture ) ;
467476 }
468477
469478 return texture ;
@@ -502,6 +511,7 @@ var TextureManager = new Class({
502511 * This is known as a JSON Array in software such as Texture Packer.
503512 *
504513 * @method Phaser.Textures.TextureManager#addAtlasJSONArray
514+ * @fires Phaser.Textures.Events#ADD
505515 * @since 3.0.0
506516 *
507517 * @param {string } key - The unique string-based key of the Texture.
@@ -542,7 +552,7 @@ var TextureManager = new Class({
542552 texture . setDataSource ( dataSource ) ;
543553 }
544554
545- this . emit ( 'addtexture' , key , texture ) ;
555+ this . emit ( Events . ADD , key , texture ) ;
546556 }
547557
548558 return texture ;
@@ -554,6 +564,7 @@ var TextureManager = new Class({
554564 * This is known as a JSON Hash in software such as Texture Packer.
555565 *
556566 * @method Phaser.Textures.TextureManager#addAtlasJSONHash
567+ * @fires Phaser.Textures.Events#ADD
557568 * @since 3.0.0
558569 *
559570 * @param {string } key - The unique string-based key of the Texture.
@@ -588,7 +599,7 @@ var TextureManager = new Class({
588599 texture . setDataSource ( dataSource ) ;
589600 }
590601
591- this . emit ( 'addtexture' , key , texture ) ;
602+ this . emit ( Events . ADD , key , texture ) ;
592603 }
593604
594605 return texture ;
@@ -599,6 +610,7 @@ var TextureManager = new Class({
599610 * in the XML format.
600611 *
601612 * @method Phaser.Textures.TextureManager#addAtlasXML
613+ * @fires Phaser.Textures.Events#ADD
602614 * @since 3.7.0
603615 *
604616 * @param {string } key - The unique string-based key of the Texture.
@@ -623,7 +635,7 @@ var TextureManager = new Class({
623635 texture . setDataSource ( dataSource ) ;
624636 }
625637
626- this . emit ( 'addtexture' , key , texture ) ;
638+ this . emit ( Events . ADD , key , texture ) ;
627639 }
628640
629641 return texture ;
@@ -634,6 +646,7 @@ var TextureManager = new Class({
634646 * The data must be in the form of a Unity YAML file.
635647 *
636648 * @method Phaser.Textures.TextureManager#addUnityAtlas
649+ * @fires Phaser.Textures.Events#ADD
637650 * @since 3.0.0
638651 *
639652 * @param {string } key - The unique string-based key of the Texture.
@@ -658,7 +671,7 @@ var TextureManager = new Class({
658671 texture . setDataSource ( dataSource ) ;
659672 }
660673
661- this . emit ( 'addtexture' , key , texture ) ;
674+ this . emit ( Events . ADD , key , texture ) ;
662675 }
663676
664677 return texture ;
@@ -682,6 +695,7 @@ var TextureManager = new Class({
682695 * same size and cannot be trimmed or rotated.
683696 *
684697 * @method Phaser.Textures.TextureManager#addSpriteSheet
698+ * @fires Phaser.Textures.Events#ADD
685699 * @since 3.0.0
686700 *
687701 * @param {string } key - The unique string-based key of the Texture.
@@ -703,7 +717,7 @@ var TextureManager = new Class({
703717
704718 Parser . SpriteSheet ( texture , 0 , 0 , 0 , width , height , config ) ;
705719
706- this . emit ( 'addtexture' , key , texture ) ;
720+ this . emit ( Events . ADD , key , texture ) ;
707721 }
708722
709723 return texture ;
@@ -729,6 +743,7 @@ var TextureManager = new Class({
729743 * same size and cannot be trimmed or rotated.
730744 *
731745 * @method Phaser.Textures.TextureManager#addSpriteSheetFromAtlas
746+ * @fires Phaser.Textures.Events#ADD
732747 * @since 3.0.0
733748 *
734749 * @param {string } key - The unique string-based key of the Texture.
@@ -768,7 +783,7 @@ var TextureManager = new Class({
768783 Parser . SpriteSheet ( texture , 0 , sheet . cutX , sheet . cutY , sheet . cutWidth , sheet . cutHeight , config ) ;
769784 }
770785
771- this . emit ( 'addtexture' , key , texture ) ;
786+ this . emit ( Events . ADD , key , texture ) ;
772787
773788 return texture ;
774789 }
0 commit comments