I would like to know how I can insert more than one mask for the same group of objects. Like to do is like in the game goof troop

I would like to reveal the objects of the same group with separate masks. in my platform game the mask of the player can touch the mask of the objects giving the effect as in the game of the goof troop.
https://drive.google.com/file/d/1W0AcSpfhLlQ0K2D-UwlFbsM8q-TyI1rn/view?usp=sharing

I think you could mask a black rect (I guess that is what you are already doing), and then create a snapshot from it and add the second mask that the snapshot group.

Thanks a lot for the help. I am trying everything in the corona, but still without success for two masks revealing my group of camera.

@andrey.freitascassio
I think you must use 2 different images and create 2 different masks. Apply the first one to the rect and the second one to the snapshot.

This is the code sample and next to it an screenshot showing the result :slight_smile:

	local mask = graphics.newMask( "images/mask.png" )
	local mask2 = graphics.newMask( "images/mask2.png" )
	
	local rect = display.newRect(screenMiddleX, screenMiddleY, screenWidth, screenHeight)
	rect.x, rect.y = 100,0
	rect:setFillColor(0)
	rect:setMask( mask )
	rect.maskX, rect.maskY = 300, 300
	
	local snapshot = display.newSnapshot(screenWidth, screenHeight)
	snapshot.x, snapshot.y = screenMiddleX, screenMiddleY
	snapshot.group:insert(rect)
	snapshot.group:setMask( mask2 )

thank you so much friend.
i am trying this way, but when i place the second mask the first disappears.

local screenMiddleX = display.contentCenterX
local screenMiddleY = display.contentCenterX
local screenWidth = display.contentWidth
local screenHeight = display.contentHeight

local mask = graphics.newMask( “mask.png” )
local mask2 = graphics.newMask( “mask2.png” )

local g = display.newGroup( )

local bg = display.newImageRect(g, “mountains.png”, 800, 900 )

g.x, g.y = 0,0
g:setMask( mask )
g.maskX, g.maskY = 0, 0

local snapshot = display.newSnapshot(screenWidth, screenHeight)
snapshot.x, snapshot.y = screenMiddleX, screenMiddleY
snapshot.group:insert(g)
snapshot.group:setMask( mask2 )

sorry, but where do I need to insert the image that I want to reveal with the two masks, in which group should I place to give this effect of two masks revealing the same object?
Tks again.

The black rectangle contains both masks and it is a completely independent thing from the rest of your scene. To move, hide or scale that rect, you should use the snapshot.group.

In other words, you should keep the snapshot.group in front of everything else (And probably inside scene.view), everything else go behind snapshot.group, but also in scene.view.

I think this code is going to help you understand:

    local screenMiddleX = display.contentCenterX
	local screenMiddleY = display.contentCenterX
	local screenWidth = display.contentWidth
	local screenHeight = display.contentHeight

	local bg = display.newImageRect(“mountains.png”, 800, 900 )

	local mask = graphics.newMask( "mask.png" )
	local mask2 = graphics.newMask( "mask2.png" )
	
	local rect = display.newRect(screenMiddleX, screenMiddleY, screenWidth, screenHeight)
	rect.x, rect.y = 100,0
	rect:setFillColor(0)
	rect:setMask( mask )
	rect.maskX, rect.maskY = 300, 300
	
	local snapshot = display.newSnapshot(screenWidth, screenHeight)
	snapshot.x, snapshot.y = screenMiddleX, screenMiddleY
	snapshot.group:insert(rect)
	snapshot.group:setMask( mask2 )