phaser/src/gameobjects/rendertexture/RenderTextureCreator.js

45 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-03-05 02:24:47 +00:00
/**
* @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');
/**
* @typedef {object} RenderTextureConfig
*
* @property {number} [x=0] - [description]
* @property {number} [y=0] - [description]
* @property {number} [width=32] - [description]
* @property {number} [height=32] - [description]
*/
2018-03-05 02:24:47 +00:00
/**
* 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 {RenderTextureConfig} config - [description]
2018-03-05 02:24:47 +00:00
*
* @return {Phaser.GameObjects.RenderTexture} The Game Object that was created.
*/
GameObjectCreator.register('renderTexture', function (config)
{
var x = GetAdvancedValue(config, 'x', 0);
var y = GetAdvancedValue(config, 'y', 0);
var width = GetAdvancedValue(config, 'width', 32);
var height = GetAdvancedValue(config, 'height', 32);
var renderTexture = new RenderTexture(this.scene, x, y, width, height);
BuildGameObject(this.scene, renderTexture, config);
return renderTexture;
});