How can I apply blur filter in Phaser 2.7

64 Views Asked by At

Hello guys can I somebody please tell me how can I apply filters in general and specifically blur filter in Phaser 2.7?

the approach I found on chatgpt is

var blurYFilter = game.add.filter('BlurY');
blurYFilter.blur = 20; // Set the blur value to 20
sprite.filters = [blurYFilter];

but this is not working. Can you please tell me the correct way to apply filters?

I am getting this error:

c.Filter[a] is not a constructor at c.GameObjectFactory.filter

1

There are 1 best solutions below

0
winner_joiner On BEST ANSWER

Checkout this official example for details. But basically you need to load the javascript files, that implement the blur filter for phaser ce.

    game.load.script('BlurX', 'BlurX.js');
    game.load.script('BlurY', 'BlurY.js');

the two files you need, can be found in the offical github repo here.