phaser/src/gameobjects/RenderTexture.js

81 lines
2.7 KiB
JavaScript
Raw Normal View History

2013-10-01 12:54:29 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2014-02-05 05:54:25 +00:00
* @copyright 2014 Photon Storm Ltd.
2013-10-01 12:54:29 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* A RenderTexture is a special texture that allows any displayObject to be rendered to it.
2013-10-01 12:54:29 +00:00
* @class Phaser.RenderTexture
* @constructor
* @param {Phaser.Game} game - Current game instance.
* @param {string} key - Internal Phaser reference key for the render texture.
* @param {number} [width=100] - The width of the render texture.
* @param {number} [height=100] - The height of the render texture.
2013-10-01 12:54:29 +00:00
*/
2014-02-07 07:32:11 +00:00
Phaser.RenderTexture = function (game, width, height, key) {
/**
2014-03-23 07:59:28 +00:00
* @property {Phaser.Game} game - A reference to the currently running game.
*/
this.game = game;
/**
* @property {string} key - The key of the RenderTexture in the Cache, if stored there.
*/
this.key = key;
/**
2014-03-23 07:59:28 +00:00
* @property {number} type - Base Phaser object type.
2013-10-01 12:54:29 +00:00
*/
this.type = Phaser.RENDERTEXTURE;
/**
* @property {Phaser.Point} _temp - Internal var.
* @private
*/
this._temp = new Phaser.Point();
2014-02-07 07:32:11 +00:00
PIXI.RenderTexture.call(this, width, height);
2014-03-23 07:59:28 +00:00
};
Phaser.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype);
Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture;
/**
* This function will draw the display object to the texture.
*
* @method Phaser.RenderTexture.prototype.renderXY
* @param {Phaser.Sprite|Phaser.Image|Phaser.Text|Phaser.BitmapText|Phaser.Group} displayObject The display object to render to this texture.
* @param {number} x - The x position to render the object at.
* @param {number} y - The y position to render the object at.
* @param {boolean} clear - If true the texture will be cleared before the display object is drawn.
*/
Phaser.RenderTexture.prototype.renderXY = function (displayObject, x, y, clear) {
this._temp.set(x, y);
this.render(displayObject, this._temp, clear);
}
// Documentation stubs
/**
* This function will draw the display object to the texture.
*
* @method Phaser.RenderTexture.prototype.render
* @param {Phaser.Sprite|Phaser.Image|Phaser.Text|Phaser.BitmapText|Phaser.Group} displayObject The display object to render to this texture.
* @param {Phaser.Point} position - A Point object containing the position to render the display object at.
* @param {boolean} clear - If true the texture will be cleared before the display object is drawn.
*/
/**
* Resize this RenderTexture to the given width and height.
*
* @method Phaser.RenderTexture.prototype.resize
* @param {number} width - The new width of the RenderTexture.
* @param {number} height - The new height of the RenderTexture.
*/