[Resolved] Setting and removing mask

Hi all,

I’m trying to set a mask on an image (orig):

function useLight()  
 if mask == nil then  
 -- Mask  
 mask = graphics.newMask(XMLPath.."circlemask.png" )  
 orig:setMask( mask )  
 orig:addEventListener( "touch", onTouch )  
 end  
end  

Works fine, the mask is in the center

Now, i remove the mask in a function:

function ClearMask()  
 orig:setMask( nil )  
 mask = nil  
end  

Works fine too.

But now if i want to set the mask again (useLight) it displays the mask in the upper left corner of the screen.

So i tried to use orig.maskX and orig.maskY to set the mask at a certain position:

function useLight()  
 if mask == nil then  
 -- Mask  
 mask = graphics.newMask(XMLPath.."circlemask.png" )  
 orig:setMask( mask )  
 orig.maskX = 400  
 orig.maskY = 600  
 orig:addEventListener( "touch", onTouch )  
 end  
end  

Result: no mask at all, at least not visible. No errors though.

What am i doing wrong here? Anyone?
[import]uid: 50459 topic_id: 26400 reply_id: 326400[/import]

Solved. I changed

orig.maskX = 400  
orig.maskY = 600  

into

orig.maskX = orig.contentWidth \* 0.5 orig.maskY = orig.contentHeight \* 0.5 [import]uid: 50459 topic_id: 26400 reply_id: 107062[/import]