phaser/src/gameobjects/shader/ShaderFactory.js

36 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-04-25 02:15:51 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2020-01-15 12:07:09 +00:00
* @copyright 2020 Photon Storm Ltd.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2019-04-25 02:15:51 +00:00
*/
var Shader = require('./Shader');
var GameObjectFactory = require('../GameObjectFactory');
/**
* Creates a new Shader Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Shader Game Object and WebGL support have been built into Phaser.
*
2019-04-25 14:07:46 +00:00
* @method Phaser.GameObjects.GameObjectFactory#shader
2019-04-25 02:15:51 +00:00
* @webglOnly
2019-04-25 14:07:46 +00:00
* @since 3.17.0
2019-04-25 02:15:51 +00:00
*
* @param {(string|Phaser.Display.BaseShader)} key - The key of the shader to use from the shader cache, or a BaseShader instance.
2019-04-25 14:07:46 +00:00
* @param {number} [x=0] - The horizontal position of this Game Object in the world.
* @param {number} [y=0] - The vertical position of this Game Object in the world.
* @param {number} [width=128] - The width of the Game Object.
* @param {number} [height=128] - The height of the Game Object.
* @param {string[]} [textures] - Optional array of texture keys to bind to the iChannel0...3 uniforms. The textures must already exist in the Texture Manager.
* @param {object} [textureData] - Optional additional texture data.
2019-04-25 02:15:51 +00:00
*
* @return {Phaser.GameObjects.Shader} The Game Object that was created.
*/
if (typeof WEBGL_RENDERER)
{
GameObjectFactory.register('shader', function (key, x, y, width, height, textures, textureData)
2019-04-25 02:15:51 +00:00
{
return this.displayList.add(new Shader(this.scene, key, x, y, width, height, textures, textureData));
2019-04-25 02:15:51 +00:00
});
}