@@ -354,6 +354,8 @@ var MultiPipeline = new Class({
354354 * @param {Phaser.GameObjects.Components.TransformMatrix } parentTransformMatrix - Parent container.
355355 * @param {boolean } [skipFlip=false] - Skip the renderTexture check.
356356 * @param {number } [textureUnit] - Use the currently bound texture unit?
357+ * @param {boolean } [cropWidth=0] - Crop the width to the given value?
358+ * @param {boolean } [cropHeight=0] - Crop the height to the given value?
357359 */
358360 batchTexture : function (
359361 gameObject ,
@@ -372,7 +374,8 @@ var MultiPipeline = new Class({
372374 camera ,
373375 parentTransformMatrix ,
374376 skipFlip ,
375- textureUnit )
377+ textureUnit ,
378+ cropWidth , cropHeight )
376379 {
377380 this . manager . set ( this , gameObject ) ;
378381
@@ -391,15 +394,18 @@ var MultiPipeline = new Class({
391394 var x = - displayOriginX ;
392395 var y = - displayOriginY ;
393396
394- if ( gameObject . isCropped )
397+ if ( gameObject . isCropped || cropWidth !== textureWidth || cropHeight !== textureHeight )
395398 {
396399 var crop = gameObject . _crop ;
397400
398- width = crop . width ;
399- height = crop . height ;
401+ cropWidth = Math . max ( crop . width , cropWidth ) ;
402+ cropHeight = Math . max ( crop . height , cropHeight ) ;
400403
401- srcWidth = crop . width ;
402- srcHeight = crop . height ;
404+ width = cropWidth ;
405+ height = cropHeight ;
406+
407+ srcWidth = cropWidth ;
408+ srcHeight = cropHeight ;
403409
404410 frameX = crop . x ;
405411 frameY = crop . y ;
@@ -409,18 +415,18 @@ var MultiPipeline = new Class({
409415
410416 if ( flipX )
411417 {
412- ox = ( frameWidth - crop . x - crop . width ) ;
418+ ox = ( frameWidth - crop . x - cropWidth ) ;
413419 }
414420
415421 if ( flipY && ! texture . isRenderTexture )
416422 {
417- oy = ( frameHeight - crop . y - crop . height ) ;
423+ oy = ( frameHeight - crop . y - cropHeight ) ;
418424 }
419425
420426 u0 = ( ox / textureWidth ) + uOffset ;
421427 v0 = ( oy / textureHeight ) + vOffset ;
422- u1 = ( ox + crop . width ) / textureWidth + uOffset ;
423- v1 = ( oy + crop . height ) / textureHeight + vOffset ;
428+ u1 = ( ox + cropWidth ) / textureWidth + uOffset ;
429+ v1 = ( oy + cropHeight ) / textureHeight + vOffset ;
424430
425431 x = - displayOriginX + frameX ;
426432 y = - displayOriginY + frameY ;
0 commit comments