javascripthtmlphaser-frameworkpixi.jsphaserjs

How can I apply blur filter in Phaser 2.7


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


Solution

  • 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.