@@ -147,27 +147,27 @@ Phaser.Loader.prototype = {
147147 * This allows you to easily make loading bars for games. Note that Sprite.visible = true will be set when calling this.
148148 *
149149 * @method Phaser.Loader#setPreloadSprite
150- * @param {Phaser.Sprite|Phaser.Image } sprite - The sprite that will be cropped during the load.
151- * @param {number } [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped.
150+ * @param {Phaser.Sprite|Phaser.Image } sprite - The sprite or image that will be cropped during the load.
151+ * @param {number } [direction=0] - A value of zero means the sprite will be cropped horizontally , a value of 1 means its will be cropped vertically .
152152 */
153153 setPreloadSprite : function ( sprite , direction ) {
154154
155155 direction = direction || 0 ;
156156
157- this . preloadSprite = { sprite : sprite , direction : direction , width : sprite . width , height : sprite . height , crop : null } ;
157+ this . preloadSprite = { sprite : sprite , direction : direction , width : sprite . width , height : sprite . height , rect : null } ;
158158
159159 if ( direction === 0 )
160160 {
161- // Horizontal crop
162- this . preloadSprite . crop = new Phaser . Rectangle ( 0 , 0 , 1 , sprite . height ) ;
161+ // Horizontal rect
162+ this . preloadSprite . rect = new Phaser . Rectangle ( 0 , 0 , 1 , sprite . height ) ;
163163 }
164164 else
165165 {
166- // Vertical crop
167- this . preloadSprite . crop = new Phaser . Rectangle ( 0 , 0 , sprite . width , 1 ) ;
166+ // Vertical rect
167+ this . preloadSprite . rect = new Phaser . Rectangle ( 0 , 0 , sprite . width , 1 ) ;
168168 }
169169
170- sprite . crop ( this . preloadSprite . crop ) ;
170+ sprite . crop ( this . preloadSprite . rect ) ;
171171
172172 sprite . visible = true ;
173173
@@ -1381,11 +1381,13 @@ Phaser.Loader.prototype = {
13811381 {
13821382 if ( this . preloadSprite . direction === 0 )
13831383 {
1384- this . preloadSprite . crop . width = Math . floor ( ( this . preloadSprite . width / 100 ) * this . progress ) ;
1384+ this . preloadSprite . rect . width = Math . floor ( ( this . preloadSprite . width / 100 ) * this . progress ) ;
1385+ this . preloadSprite . sprite . crop ( this . preloadSprite . rect ) ;
13851386 }
13861387 else
13871388 {
1388- this . preloadSprite . crop . height = Math . floor ( ( this . preloadSprite . height / 100 ) * this . progress ) ;
1389+ this . preloadSprite . rect . height = Math . floor ( ( this . preloadSprite . height / 100 ) * this . progress ) ;
1390+ this . preloadSprite . sprite . crop ( this . preloadSprite . rect ) ;
13891391 }
13901392 }
13911393
0 commit comments