Skip to content

Commit 782a841

Browse files
committed
Added getPostPipeline method
1 parent 0658820 commit 782a841

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

src/gameobjects/components/Pipeline.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,15 @@ var Pipeline = {
161161
* Post Pipelines are invoked after this Game Object has rendered to its target and
162162
* are commonly used for post-fx.
163163
*
164-
* The post pipelines instances are appended to the `postPipelines` array belonging to this
164+
* The post pipelines are appended to the `postPipelines` array belonging to this
165165
* Game Object. When the renderer processes this Game Object, it iterates through the post
166166
* pipelines in the order in which they appear in the array. If you are stacking together
167167
* multiple effects, be aware that the order is important.
168168
*
169169
* If you call this method multiple times, the new pipelines will be appended to any existing
170170
* post pipelines already set. Use the `resetPostPipeline` method to clear them first, if required.
171171
*
172-
* You can optionally also sets the `pipelineData` property, if the parameter is given
173-
* and the pipeline is successfully set.
172+
* You can optionally also sets the `pipelineData` property, if the parameter is given.
174173
*
175174
* Both the pipeline and post pipelines share the pipeline data object together.
176175
*
@@ -251,6 +250,32 @@ var Pipeline = {
251250
return this;
252251
},
253252

253+
/**
254+
* Gets a Post Pipeline instance from this Game Object, based on the given name, and returns it.
255+
*
256+
* @method Phaser.GameObjects.Components.Pipeline#getPostPipeline
257+
* @webglOnly
258+
* @since 3.50.0
259+
*
260+
* @param {string} name - The name of the Post Pipeline to get.
261+
*
262+
* @return {Phaser.Renderer.WebGL.Pipelines.PostFXPipeline} The first Post Pipeline matching the name, or undefined if no match.
263+
*/
264+
getPostPipeline: function (pipeline)
265+
{
266+
var pipelines = this.postPipelines;
267+
268+
for (var i = 0; i < pipelines.length; i++)
269+
{
270+
var instance = pipelines[i];
271+
272+
if ((typeof pipeline === 'string' && instance.name === name) || instance instanceof pipeline)
273+
{
274+
return instance;
275+
}
276+
}
277+
},
278+
254279
/**
255280
* Resets the WebGL Pipeline of this Game Object back to the default it was created with.
256281
*

0 commit comments

Comments
 (0)