1717* @param {number } [height=100] - The height of the render texture.
1818* @param {string } [key=''] - The key of the RenderTexture in the Cache, if stored there.
1919* @param {number } [scaleMode=Phaser.scaleModes.DEFAULT] - One of the Phaser.scaleModes consts.
20+ * @param {number } [resolution=1] - The resolution of the texture being generated.
2021*/
21- Phaser . RenderTexture = function ( game , width , height , key , scaleMode ) {
22+ Phaser . RenderTexture = function ( game , width , height , key , scaleMode , resolution ) {
2223
2324 if ( typeof key === 'undefined' ) { key = '' ; }
2425 if ( typeof scaleMode === 'undefined' ) { scaleMode = Phaser . scaleModes . DEFAULT ; }
26+ if ( typeof resolution === 'undefined' ) { resolution = 1 ; }
2527
2628 /**
2729 * @property {Phaser.Game } game - A reference to the currently running game.
@@ -39,12 +41,13 @@ Phaser.RenderTexture = function (game, width, height, key, scaleMode) {
3941 this . type = Phaser . RENDERTEXTURE ;
4042
4143 /**
42- * @property {Phaser.Point } _temp - Internal var.
43- * @private
44+ * @property {PIXI.Matrix } matrix - The matrix that is applied when display objects are rendered to this RenderTexture.
4445 */
45- this . _temp = new Phaser . Point ( ) ;
46+ this . matrix = new PIXI . Matrix ( ) ;
4647
47- PIXI . RenderTexture . call ( this , width , height , this . game . renderer , scaleMode ) ;
48+ PIXI . RenderTexture . call ( this , width , height , this . game . renderer , scaleMode , resolution ) ;
49+
50+ this . render = Phaser . RenderTexture . prototype . render ;
4851
4952} ;
5053
@@ -62,14 +65,20 @@ Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture;
6265*/
6366Phaser . RenderTexture . prototype . renderXY = function ( displayObject , x , y , clear ) {
6467
65- this . _temp . set ( x , y ) ;
68+ this . matrix . tx = x ;
69+ this . matrix . ty = y ;
6670
67- this . render ( displayObject , this . _temp , clear ) ;
71+ if ( this . renderer . type === PIXI . WEBGL_RENDERER )
72+ {
73+ this . renderWebGL ( displayObject , this . matrix , clear ) ;
74+ }
75+ else
76+ {
77+ this . renderCanvas ( displayObject , this . matrix , clear ) ;
78+ }
6879
6980} ;
7081
71- // Documentation stubs
72-
7382/**
7483* This function will draw the display object to the texture.
7584*
@@ -78,11 +87,18 @@ Phaser.RenderTexture.prototype.renderXY = function (displayObject, x, y, clear)
7887* @param {Phaser.Point } position - A Point object containing the position to render the display object at.
7988* @param {boolean } clear - If true the texture will be cleared before the display object is drawn.
8089*/
90+ Phaser . RenderTexture . prototype . render = function ( displayObject , position , clear ) {
8191
82- /**
83- * Resize this RenderTexture to the given width and height.
84- *
85- * @method Phaser.RenderTexture.prototype.resize
86- * @param {number } width - The new width of the RenderTexture.
87- * @param {number } height - The new height of the RenderTexture.
88- */
92+ this . matrix . tx = position . x ;
93+ this . matrix . ty = position . y ;
94+
95+ if ( this . renderer . type === PIXI . WEBGL_RENDERER )
96+ {
97+ this . renderWebGL ( displayObject , this . matrix , clear ) ;
98+ }
99+ else
100+ {
101+ this . renderCanvas ( displayObject , this . matrix , clear ) ;
102+ }
103+
104+ } ;
0 commit comments