I’m attempting to blur the map using Snapshots and some code posted to the forums (thanks to Ingemar), so that when a user presses a button to bring up a menu it blurs the map in the background:
[lua]
local addBlurEffect = function(grp, blur)
local innerSnapshot = display.newSnapshot(grp.width+blur/2, grp.height+blur/2);
innerSnapshot.canvas:insert(grp);
innerSnapshot.canvasMode = “discard”;
innerSnapshot.fill.effect = “filter.blurGaussian”;
innerSnapshot.fill.effect.horizontal.blurSize = blur;
innerSnapshot.fill.effect.vertical.blurSize = blur;
innerSnapshot:invalidate(“canvas”);
local outerSnapshot = display.newSnapshot(innerSnapshot.width, innerSnapshot.height);
outerSnapshot.canvas:insert(innerSnapshot);
outerSnapshot.canvasMode = “discard”;
outerSnapshot:invalidate(“canvas”);
return outerSnapshot;
end
local blurryGroup = addBlurEffect(grp, 300);
blurryGroup:translate(display.contentCenterX, display.contentCenterY);
[/lua]
I’m using what’s returned from mte.getMapObj() as the first argument for addBlurEffect, however because this code inserts the MTE group into the snapshot it causes an issue when mte:update() is called presumably because the group has been moved/inserted into another.
mte.lua:13281: attempt to compare nil with number
[lua]
if displayGroups[i].alpha <= 0 and displayGroups[i].isVisible then
[/lua]
Is anybody aware of a solution or an alternative method of achieving this effect? TBH I haven’t had the time to check out G2.0 fully yet, and was just having 20 minutes to experiment so I could be doing this completely wrong.
Many thanks…
For some reason that formatting isn’t very nice - so here’s a link to the original code by Ingemar:
http://forums.coronalabs.com/topic/42000-effect-aplied-to-the-entire-group/