@@ -30,6 +30,7 @@ var SpriteBatch = new Class({
3030 this . currentTexture2D = null ;
3131 this . viewMatrixLocation = null ;
3232 this . tempMatrix = new TransformMatrix ( ) ;
33+ this . usingRenderTexture = false ;
3334
3435 // All of these settings will be able to be controlled via the Game Config
3536 this . config = {
@@ -369,7 +370,7 @@ var SpriteBatch = new Class({
369370 }
370371 } ,
371372
372- addTileTextureRect : function ( texture , x , y , width , height , alpha , tint , scrollFactorX , scrollFactorY , textureWidth , textureHeight , rectX , rectY , rectW , rectH , camera , renderTarget )
373+ addTileTextureRect : function ( texture , x , y , width , height , alpha , tint , scrollFactorX , scrollFactorY , textureWidth , textureHeight , rectX , rectY , rectW , rectH , camera , renderTarget , flipX , flipY )
373374 {
374375 var vertexDataBuffer = this . vertexDataBuffer ;
375376 var vertexBufferObjectF32 = vertexDataBuffer . floatView ;
@@ -382,6 +383,14 @@ var SpriteBatch = new Class({
382383 var scrollY = camera . scrollY * scrollFactorY ;
383384 var mva , mvb , mvc , mvd , mve , mvf , tx0 , ty0 , tx1 , ty1 , tx2 , ty2 , tx3 , ty3 ;
384385
386+ flipX = flipX ? flipX : false ;
387+ flipY = flipY ? flipY : false ;
388+
389+ rectW = rectW * ( flipX ? - 1 : 1 ) ;
390+ rectH = rectH * ( flipY ? - 1 : 1 ) ;
391+ rectX = flipX ? - rectW : rectX ;
392+ rectY = flipY ? - rectH : rectY ;
393+
385394 // Inset UV coordinates by 0.5px to prevent tile bleeding
386395 var u0 = ( rectX + 0.5 ) / textureWidth ;
387396 var v0 = ( rectY + 0.5 ) / textureHeight ;
@@ -446,16 +455,19 @@ var SpriteBatch = new Class({
446455 var vertexBufferObjectF32 = vertexDataBuffer . floatView ;
447456 var vertexBufferObjectU32 = vertexDataBuffer . uintView ;
448457 var vertexOffset = 0 ;
449- var width = rectWidth * ( gameObject . flipX ? - 1 : 1 ) ;
450- var height = rectHeight * ( gameObject . flipY ? - 1 : 1 ) ;
458+ var forceFlipY = ( texture . isRenderTexture ? true : false ) ;
459+ var flipX = gameObject . flipX ;
460+ var flipY = gameObject . flipY ^ forceFlipY ;
461+ var width = rectWidth * ( flipX ? - 1 : 1 ) ;
462+ var height = rectHeight * ( flipY ? - 1 : 1 ) ;
451463 var translateX = gameObject . x - camera . scrollX * gameObject . scrollFactorX ;
452464 var translateY = gameObject . y - camera . scrollY * gameObject . scrollFactorY ;
453465 var scaleX = gameObject . scaleX ;
454466 var scaleY = gameObject . scaleY ;
455467 var rotation = - gameObject . rotation ;
456468 var tempMatrixMatrix = tempMatrix . matrix ;
457- var x = - gameObject . displayOriginX + ( ( rectWidth ) * ( gameObject . flipX ? 1 : 0.0 ) ) ;
458- var y = - gameObject . displayOriginY + ( ( rectHeight ) * ( gameObject . flipY ? 1 : 0.0 ) ) ;
469+ var x = - gameObject . displayOriginX + ( ( rectWidth ) * ( flipX ? 1 : 0.0 ) ) ;
470+ var y = - gameObject . displayOriginY + ( ( rectHeight ) * ( flipY ? 1 : 0.0 ) ) ;
459471 var xw = x + rectWidth ;
460472 var yh = y + rectHeight ;
461473 var cameraMatrix = camera . matrix . matrix ;
@@ -552,16 +564,19 @@ var SpriteBatch = new Class({
552564 var vertexBufferObjectF32 = vertexDataBuffer . floatView ;
553565 var vertexBufferObjectU32 = vertexDataBuffer . uintView ;
554566 var vertexOffset = 0 ;
555- var width = textureWidth * ( gameObject . flipX ? - 1 : 1 ) ;
556- var height = textureHeight * ( gameObject . flipY ? - 1 : 1 ) ;
567+ var forceFlipY = ( texture . isRenderTexture ? true : false ) ;
568+ var flipX = gameObject . flipX ;
569+ var flipY = gameObject . flipY ^ forceFlipY ;
570+ var width = textureWidth * ( flipX ? - 1 : 1 ) ;
571+ var height = textureHeight * ( flipY ? - 1 : 1 ) ;
557572 var translateX = gameObject . x - camera . scrollX * gameObject . scrollFactorX ;
558573 var translateY = gameObject . y - camera . scrollY * gameObject . scrollFactorY ;
559574 var scaleX = gameObject . scaleX ;
560575 var scaleY = gameObject . scaleY ;
561576 var rotation = - gameObject . rotation ;
562577 var tempMatrixMatrix = tempMatrix . matrix ;
563- var x = - gameObject . displayOriginX + ( ( textureWidth ) * ( gameObject . flipX ? 1 : 0.0 ) ) ;
564- var y = - gameObject . displayOriginY + ( ( textureHeight ) * ( gameObject . flipY ? 1 : 0.0 ) ) ;
578+ var x = - gameObject . displayOriginX + ( ( textureWidth ) * ( flipX ? 1 : 0.0 ) ) ;
579+ var y = - gameObject . displayOriginY + ( ( textureHeight ) * ( flipY ? 1 : 0.0 ) ) ;
565580 var xw = x + width ;
566581 var yh = y + height ;
567582 var cameraMatrix = camera . matrix . matrix ;
0 commit comments