I was just wondering what methods I could use to blur the entire screen. I know there’s a function that can blur a single image, but I want to blur the entire screen when the player pauses the game. Thanks for your help in advance!
If you have SSK2 lite or PRO, you can do this in one line:
https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/misc/#easyblur
ssk.misc.easyBlur( )
I wonder if it can be done without your great and awesome library SSK2 and with free version of Corona?
I wonder the same thing
@roaminggamer’s library looks great but It’d be nice to know how to do this straight up with Corona.
It certainly can be done w/o SSK2. It takes about 30 lines of code depending on what you want the effect to look like.
- capture the screen
- blur it
- handle various effects as needed
- add touch handlers
- manage the object
- …
PS - SSK2 is pure Lua + Corona btw and when you have it, you have access to all of the code so you can modify bits and pieces if they don’t fit your needs. The only limit is you can’t share any parts (code or other) of the library in the forums or elsewhere.
It is quite easy to blur the entire screen. Just take a screenshot and put a blur filter on it. Here is a module you can require to do it.
But remember you have to pause everything else in your game too.
-- ------------------------------------------------------------------------------- -- pause.lua -- ------------------------------------------------------------------------------- local \_M = {} local capture function \_M.start() capture = display.captureScreen() capture.x, capture.y = display.contentCenterX, display.contentCenterY capture.fill.effect = "filter.blurGaussian" capture.fill.effect.horizontal.blurSize = 20 capture.fill.effect.vertical.blurSize = 20 end function \_M.stop() display.remove(capture) capture = nil end return \_M
Thank you! This works, although I’m not able to create any new Rects on top of the capture. Here’s some of my code;
function pauseGame() gamePaused = true pauseButton.alpha = 0 pauseSide1.alpha = 0 pauseSide2.alpha = 0 capture = display.captureScreen() capture.x, capture.y = display.contentCenterX, display.contentCenterY capture.fill.effect = "filter.blurGaussian" capture.fill.effect.horizontal.blurSize = 1000 capture.fill.effect.vertical.blurSize = 1000--]] timer.pause(obstacleScrollTimer) if gameOverTimer ~= nil then timer.pause(gameOverTimer) end transition.pause() pauseScreen = display.newRect(screenW/2, screenH/2, 1000, 2000) -- The following Rects don't appear on top of the capture, how can I fix that? pauseScreen:setFillColor(.1) pauseScreen.alpha = .6 sceneGroup:insert(pauseScreen) backButton = display.newRect(screenW/2 - 200, screenH/2 + 200, 200, 200) backButton:setFillColor(0,.5,1) sceneGroup:insert(backButton) backButton:toFront() playButton = display.newRect(screenW/2 + 100, screenH/2 + 200, 300, 300) sceneGroup:insert(playButton) playButton:toFront() end
In my code the screencapture is not inserted into any group. If you need to place other display objects on top of the capture you need to put it into the sceneGroup in your code. sceneGroup:insert(capture)
Awesome! Thank you!
Use filter.blurGaussian with caution! My app was really slow on my iPad and even my powerful iMac turned the fan on when I used the simulator. After some hours searching I finally found out that the filter.blurGaussian caused it.
How frequently were you blurring?
15 of 35 scenes had one background image with the blur effect. I use composer.removeHidden() to remove all the scenes in the background.
It seemed like the app slowed down pretty quickly after the first scene. Everything was lagging like I had 10 fps
I ended up making the blurred images in photoshop and the app worked perfectly again
You can use the blur filter, save a snapshot of the image, destroy the original and then load the snapshot. Only need to do this the first time the app is loaded. I did this when I needed 500 pics all to have a random filter applied.
That was really clever B) I didn’t bother to find a workaround since I only had 15 pics, but if I have more on another project I will use your trick
If you have SSK2 lite or PRO, you can do this in one line:
https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/misc/#easyblur
ssk.misc.easyBlur( )
I wonder if it can be done without your great and awesome library SSK2 and with free version of Corona?
I wonder the same thing
@roaminggamer’s library looks great but It’d be nice to know how to do this straight up with Corona.
It certainly can be done w/o SSK2. It takes about 30 lines of code depending on what you want the effect to look like.
- capture the screen
- blur it
- handle various effects as needed
- add touch handlers
- manage the object
- …
PS - SSK2 is pure Lua + Corona btw and when you have it, you have access to all of the code so you can modify bits and pieces if they don’t fit your needs. The only limit is you can’t share any parts (code or other) of the library in the forums or elsewhere.
It is quite easy to blur the entire screen. Just take a screenshot and put a blur filter on it. Here is a module you can require to do it.
But remember you have to pause everything else in your game too.
-- ------------------------------------------------------------------------------- -- pause.lua -- ------------------------------------------------------------------------------- local \_M = {} local capture function \_M.start() capture = display.captureScreen() capture.x, capture.y = display.contentCenterX, display.contentCenterY capture.fill.effect = "filter.blurGaussian" capture.fill.effect.horizontal.blurSize = 20 capture.fill.effect.vertical.blurSize = 20 end function \_M.stop() display.remove(capture) capture = nil end return \_M
Thank you! This works, although I’m not able to create any new Rects on top of the capture. Here’s some of my code;
function pauseGame() gamePaused = true pauseButton.alpha = 0 pauseSide1.alpha = 0 pauseSide2.alpha = 0 capture = display.captureScreen() capture.x, capture.y = display.contentCenterX, display.contentCenterY capture.fill.effect = "filter.blurGaussian" capture.fill.effect.horizontal.blurSize = 1000 capture.fill.effect.vertical.blurSize = 1000--]] timer.pause(obstacleScrollTimer) if gameOverTimer ~= nil then timer.pause(gameOverTimer) end transition.pause() pauseScreen = display.newRect(screenW/2, screenH/2, 1000, 2000) -- The following Rects don't appear on top of the capture, how can I fix that? pauseScreen:setFillColor(.1) pauseScreen.alpha = .6 sceneGroup:insert(pauseScreen) backButton = display.newRect(screenW/2 - 200, screenH/2 + 200, 200, 200) backButton:setFillColor(0,.5,1) sceneGroup:insert(backButton) backButton:toFront() playButton = display.newRect(screenW/2 + 100, screenH/2 + 200, 300, 300) sceneGroup:insert(playButton) playButton:toFront() end