new RenderTexture(width, height, renderer, scaleMode, resolution)
A RenderTexture is a special texture that allows any Pixi display object to be rendered to it.
Hint: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded otherwise black rectangles will be drawn instead.
A RenderTexture takes a snapshot of any Display Object given to its render method. The position and rotation of the given Display Objects is ignored. For example:
var renderTexture = new PIXI.RenderTexture(800, 600);
var sprite = PIXI.Sprite.fromImage("spinObj_01.png");
sprite.position.x = 800/2;
sprite.position.y = 600/2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
renderTexture.render(sprite);
The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual position a DisplayObjectContainer should be used:
var doc = new PIXI.DisplayObjectContainer();
doc.addChild(sprite);
renderTexture.render(doc); // Renders to center of renderTexture
Parameters
Name | Type | Description |
---|---|---|
width | Number | The width of the render texture |
height | Number | The height of the render texture |
renderer | PIXI.CanvasRenderer | PIXI.WebGLRenderer | The renderer used for this RenderTexture |
scaleMode | Number | See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values |
resolution | Number | The resolution of the texture being generated |
- Source code: pixi/textures/RenderTexture.js (Line 5)
Please login to continue.