@@ -253,7 +253,7 @@ Phaser.Cache.prototype = {
253253 */
254254 addSpriteSheet : function ( key , url , data , frameWidth , frameHeight , frameMax , margin , spacing ) {
255255
256- this . _images [ key ] = { url : url , data : data , spriteSheet : true , frameWidth : frameWidth , frameHeight : frameHeight , margin : margin , spacing : spacing } ;
256+ this . _images [ key ] = { url : url , data : data , frameWidth : frameWidth , frameHeight : frameHeight , margin : margin , spacing : spacing } ;
257257
258258 PIXI . BaseTextureCache [ key ] = new PIXI . BaseTexture ( data ) ;
259259 PIXI . TextureCache [ key ] = new PIXI . Texture ( PIXI . BaseTextureCache [ key ] ) ;
@@ -289,7 +289,7 @@ Phaser.Cache.prototype = {
289289 */
290290 addTextureAtlas : function ( key , url , data , atlasData , format ) {
291291
292- this . _images [ key ] = { url : url , data : data , spriteSheet : true } ;
292+ this . _images [ key ] = { url : url , data : data } ;
293293
294294 PIXI . BaseTextureCache [ key ] = new PIXI . BaseTexture ( data ) ;
295295 PIXI . TextureCache [ key ] = new PIXI . Texture ( PIXI . BaseTextureCache [ key ] ) ;
@@ -322,7 +322,7 @@ Phaser.Cache.prototype = {
322322 */
323323 addBitmapFont : function ( key , url , data , xmlData , xSpacing , ySpacing ) {
324324
325- this . _images [ key ] = { url : url , data : data , spriteSheet : true } ;
325+ this . _images [ key ] = { url : url , data : data } ;
326326
327327 PIXI . BaseTextureCache [ key ] = new PIXI . BaseTexture ( data ) ;
328328 PIXI . TextureCache [ key ] = new PIXI . Texture ( PIXI . BaseTextureCache [ key ] ) ;
@@ -422,9 +422,11 @@ Phaser.Cache.prototype = {
422422 */
423423 addImage : function ( key , url , data ) {
424424
425- this . _images [ key ] = { url : url , data : data , spriteSheet : false } ;
425+ this . _images [ key ] = { url : url , data : data } ;
426426
427427 this . _images [ key ] . frame = new Phaser . Frame ( 0 , 0 , 0 , data . width , data . height , key , this . game . rnd . uuid ( ) ) ;
428+ this . _images [ key ] . frameData = new Phaser . FrameData ( ) ;
429+ this . _images [ key ] . frameData . addFrame ( new Phaser . Frame ( 0 , 0 , 0 , data . width , data . height , url , this . game . rnd . uuid ( ) ) ) ;
428430
429431 PIXI . BaseTextureCache [ key ] = new PIXI . BaseTexture ( data ) ;
430432 PIXI . TextureCache [ key ] = new PIXI . Texture ( PIXI . BaseTextureCache [ key ] ) ;
@@ -859,7 +861,7 @@ Phaser.Cache.prototype = {
859861 */
860862 getFrameData : function ( key ) {
861863
862- if ( this . _images [ key ] && this . _images [ key ] . frameData )
864+ if ( this . _images [ key ] )
863865 {
864866 return this . _images [ key ] . frameData ;
865867 }
@@ -878,7 +880,6 @@ Phaser.Cache.prototype = {
878880
879881 if ( this . _images [ key ] )
880882 {
881- this . _images [ key ] . spriteSheet = true ;
882883 this . _images [ key ] . frameData = frameData ;
883884 }
884885
@@ -893,7 +894,7 @@ Phaser.Cache.prototype = {
893894 */
894895 getFrameByIndex : function ( key , frame ) {
895896
896- if ( this . _images [ key ] && this . _images [ key ] . frameData )
897+ if ( this . _images [ key ] )
897898 {
898899 return this . _images [ key ] . frameData . getFrame ( frame ) ;
899900 }
@@ -910,7 +911,7 @@ Phaser.Cache.prototype = {
910911 */
911912 getFrameByName : function ( key , frame ) {
912913
913- if ( this . _images [ key ] && this . _images [ key ] . frameData )
914+ if ( this . _images [ key ] )
914915 {
915916 return this . _images [ key ] . frameData . getFrameByName ( frame ) ;
916917 }
@@ -927,7 +928,7 @@ Phaser.Cache.prototype = {
927928 */
928929 getFrame : function ( key ) {
929930
930- if ( this . _images [ key ] && this . _images [ key ] . spriteSheet === false )
931+ if ( this . _images [ key ] )
931932 {
932933 return this . _images [ key ] . frame ;
933934 }
@@ -1042,20 +1043,20 @@ Phaser.Cache.prototype = {
10421043 } ,
10431044
10441045 /**
1045- * Check whether an image asset is sprite sheet or not .
1046+ * Get the number of frames in this image .
10461047 *
1047- * @method Phaser.Cache#isSpriteSheet
1048- * @param {string } key - Asset key of the sprite sheet you want.
1049- * @return {boolean } True if the image is a sprite sheet .
1048+ * @method Phaser.Cache#getFrameCount
1049+ * @param {string } key - Asset key of the image you want.
1050+ * @return {integer } Then number of frames. 0 if the image is not found .
10501051 */
1051- isSpriteSheet : function ( key ) {
1052+ getFrameCount : function ( key ) {
10521053
10531054 if ( this . _images [ key ] )
10541055 {
1055- return this . _images [ key ] . spriteSheet ;
1056+ return this . _images [ key ] . frameData . total ;
10561057 }
10571058
1058- return false ;
1059+ return 0 ;
10591060
10601061 } ,
10611062
0 commit comments