Add multiple masks to an image?

So far it seems that I can’s add multiple masks to the same image.

-- add background  
local background = display.newImageRect( "images/bkg\_1\_sqr.png", 768, 1024 )  
background.x, background.y = halfW, halfH  
-- card hole  
local cardHoleMask = graphics.newMask("images/card\_mask\_sqr.png")   
background:setMask(cardHoleMask)  
-- clock hole  
local clockHoleMask = graphics.newMask("images/clock\_mask.png")  
background:setMask(clockHoleMask)  
group:insert(background)  

The 2nd mask shows up but not the first.

Am I doing it wrong? Or is there a way around this? [import]uid: 136105 topic_id: 33826 reply_id: 333826[/import]

You’re doing it wrong, I’m afraid. You can only set one mask to a display object at a time - calling :setMask again will overwrite the first mask with the second.

Use multiple display groups…

[lua]-- create groups
local container, innercontainer = display.newGroup(), display.newGroup()

– insert inner container into top level container
container:insert(innercontainer)

– add background - insert background into innercontainer
local background = display.newImageRect( innercontainer, “images/bkg_1_sqr.png”, 768, 1024 )
background.x, background.y = halfW, halfH

– card hole
local cardHoleMask = graphics.newMask(“images/card_mask_sqr.png”)
container:setMask(cardHoleMask)

– clock hole
local clockHoleMask = graphics.newMask(“images/clock_mask.png”)
innercontainer:setMask(clockHoleMask)

– insert top-level group into scene (I assume)
group:insert(container)[/lua] [import]uid: 8271 topic_id: 33826 reply_id: 134476[/import]

You’re doing it wrong, I’m afraid. You can only set one mask to a display object at a time - calling :setMask again will overwrite the first mask with the second.

Use multiple display groups…

[lua]-- create groups
local container, innercontainer = display.newGroup(), display.newGroup()

– insert inner container into top level container
container:insert(innercontainer)

– add background - insert background into innercontainer
local background = display.newImageRect( innercontainer, “images/bkg_1_sqr.png”, 768, 1024 )
background.x, background.y = halfW, halfH

– card hole
local cardHoleMask = graphics.newMask(“images/card_mask_sqr.png”)
container:setMask(cardHoleMask)

– clock hole
local clockHoleMask = graphics.newMask(“images/clock_mask.png”)
innercontainer:setMask(clockHoleMask)

– insert top-level group into scene (I assume)
group:insert(container)[/lua] [import]uid: 8271 topic_id: 33826 reply_id: 134476[/import]