mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Added jsdocs
This commit is contained in:
parent
4d16b0c00a
commit
4c59d9a35d
7 changed files with 175 additions and 7 deletions
|
@ -1,11 +1,49 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var CanvasPool = require('../../display/canvas/CanvasPool');
|
||||
var Class = require('../../utils/Class');
|
||||
var Components = require('../components');
|
||||
var CONST = require('../../const');
|
||||
var GameObject = require('../GameObject');
|
||||
var RenderTextureWebGL = require('./RenderTextureWebGL');
|
||||
var RenderTextureCanvas = require('./RenderTextureCanvas');
|
||||
var Render = require('./RenderTextureRender');
|
||||
var CanvasPool = require('../../display/canvas/CanvasPool');
|
||||
var RenderTextureCanvas = require('./RenderTextureCanvas');
|
||||
var RenderTextureWebGL = require('./RenderTextureWebGL');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* A Render Texture.
|
||||
*
|
||||
* @class RenderTexture
|
||||
* @extends Phaser.GameObjects.GameObject
|
||||
* @memberOf Phaser.GameObjects
|
||||
* @constructor
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @extends Phaser.GameObjects.Components.Alpha
|
||||
* @extends Phaser.GameObjects.Components.BlendMode
|
||||
* @extends Phaser.GameObjects.Components.Depth
|
||||
* @extends Phaser.GameObjects.Components.Flip
|
||||
* @extends Phaser.GameObjects.Components.GetBounds
|
||||
* @extends Phaser.GameObjects.Components.MatrixStack
|
||||
* @extends Phaser.GameObjects.Components.Origin
|
||||
* @extends Phaser.GameObjects.Components.Pipeline
|
||||
* @extends Phaser.GameObjects.Components.ScaleMode
|
||||
* @extends Phaser.GameObjects.Components.ScrollFactor
|
||||
* @extends Phaser.GameObjects.Components.Size
|
||||
* @extends Phaser.GameObjects.Components.Tint
|
||||
* @extends Phaser.GameObjects.Components.Transform
|
||||
* @extends Phaser.GameObjects.Components.Visible
|
||||
*
|
||||
* @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
|
||||
* @param {number} x - The horizontal position of this Game Object in the world.
|
||||
* @param {number} y - The vertical position of this Game Object in the world.
|
||||
* @param {integer} [width=32] - The width of the Render Texture.
|
||||
* @param {integer} [height=32] - The height of the Render Texture.
|
||||
*/
|
||||
var RenderTexture = new Class({
|
||||
|
||||
Extends: GameObject,
|
||||
|
@ -32,12 +70,16 @@ var RenderTexture = new Class({
|
|||
|
||||
function RenderTexture (scene, x, y, width, height)
|
||||
{
|
||||
if (width === undefined) { width = 32; }
|
||||
if (height === undefined) { height = 32; }
|
||||
|
||||
GameObject.call(this, scene, 'RenderTexture');
|
||||
|
||||
this.initMatrixStack();
|
||||
|
||||
this.renderer = scene.sys.game.renderer;
|
||||
|
||||
if (this.renderer.type === Phaser.WEBGL)
|
||||
if (this.renderer.type === CONST.WEBGL)
|
||||
{
|
||||
var gl = this.renderer.gl;
|
||||
this.gl = gl;
|
||||
|
@ -48,7 +90,7 @@ var RenderTexture = new Class({
|
|||
this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false);
|
||||
this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false);
|
||||
}
|
||||
else
|
||||
else if (this.renderer.type === CONST.CANVAS)
|
||||
{
|
||||
this.fill = RenderTextureCanvas.fill;
|
||||
this.clear = RenderTextureCanvas.clear;
|
||||
|
@ -63,16 +105,57 @@ var RenderTexture = new Class({
|
|||
this.initPipeline('TextureTintPipeline');
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#destroy
|
||||
* @since 3.2.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
GameObject.destroy.call(this);
|
||||
if (this.renderer.type === Phaser.WEBGL)
|
||||
|
||||
if (this.renderer.type === CONST.WEBGL)
|
||||
{
|
||||
this.renderer.deleteTexture(this.texture);
|
||||
this.renderer.deleteFramebuffer(this.framebuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the Render Texture with the given color.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#fill
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} rgb - The color to fill the Render Texture with.
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} This Game Object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Clears the Render Texture.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#clear
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} This Game Object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Draws a texture frame to the Render Texture at the given position.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#draw
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
|
||||
* @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with.
|
||||
* @param {number} x - The x position to draw the frame at.
|
||||
* @param {number} y - The y position to draw the frame at.
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} This Game Object.
|
||||
*/
|
||||
|
||||
});
|
||||
|
||||
module.exports = RenderTexture;
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var GameObject = require('../GameObject');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the Canvas Renderer to the given Camera.
|
||||
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
|
||||
* This method should not be called directly. It is a utility function of the Render module.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#renderCanvas
|
||||
* @since 3.2.0
|
||||
* @private
|
||||
*
|
||||
* @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer.
|
||||
* @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
*/
|
||||
var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id)))
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
var GameObjectCreator = require('../GameObjectCreator');
|
||||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var RenderTexture = require('./RenderTexture');
|
||||
|
||||
/**
|
||||
* Creates a new Render Texture Game Object and returns it.
|
||||
*
|
||||
* Note: This method will only be available if the Render Texture Game Object has been built into Phaser.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectCreator#renderTexture
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} The Game Object that was created.
|
||||
*/
|
||||
GameObjectCreator.register('renderTexture', function (config)
|
||||
{
|
||||
var x = GetAdvancedValue(config, 'x', 0);
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var GameObjectFactory = require('../GameObjectFactory');
|
||||
var RenderTexture = require('./RenderTexture');
|
||||
|
||||
/**
|
||||
* Creates a new Render Texture Game Object and adds it to the Scene.
|
||||
*
|
||||
* Note: This method will only be available if the Render Texture Game Object has been built into Phaser.
|
||||
*
|
||||
* @method Phaser.GameObjects.GameObjectFactory#renderTexture
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param {number} x - The horizontal position of this Game Object in the world.
|
||||
* @param {number} y - The vertical position of this Game Object in the world.
|
||||
* @param {integer} [width=32] - The width of the Render Texture.
|
||||
* @param {integer} [height=32] - The height of the Render Texture.
|
||||
*
|
||||
* @return {Phaser.GameObjects.RenderTexture} The Game Object that was created.
|
||||
*/
|
||||
GameObjectFactory.register('renderTexture', function (x, y, width, height)
|
||||
{
|
||||
return this.displayList.add(new RenderTexture(this.scene, x, y, width, height));
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var renderWebGL = require('../../utils/NOOP');
|
||||
var renderCanvas = require('../../utils/NOOP');
|
||||
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2018 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
var GameObject = require('../GameObject');
|
||||
|
||||
/**
|
||||
* Renders this Game Object with the Canvas Renderer to the given Camera.
|
||||
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
|
||||
* This method should not be called directly. It is a utility function of the Render module.
|
||||
*
|
||||
* @method Phaser.GameObjects.RenderTexture#renderWebgl
|
||||
* @since 3.2.0
|
||||
* @private
|
||||
*
|
||||
* @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active Canvas renderer.
|
||||
* @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call.
|
||||
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
|
||||
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
|
||||
*/
|
||||
var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera)
|
||||
{
|
||||
if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id)))
|
||||
|
|
|
@ -117,7 +117,7 @@ var Sprite = new Class({
|
|||
* @param {boolean} ignoreIfPlaying - [description]
|
||||
* @param {integer|string} startFrame - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
* @return {Phaser.GameObjects.Sprite} This Game Object.
|
||||
*/
|
||||
play: function (key, ignoreIfPlaying, startFrame)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue