Mask function is not correct in Scene

HI
Recently, I want to do a image mask in director scene.
But the response is not correct, The screen can not show masked image.
I using trial version 2011.704 with director class 1.4
the mask function not work correctly

here is the code (I change it from example file X-ray)

=====
main.lua

  
local main = function ()  
  
 ------------------  
 -- Add the group from director class  
 ------------------  
  
 mainGroup:insert(director.directorView)  
  
 ------------------  
 -- Change scene without effects  
 ------------------  
  
 director:changeScene("test")  
  
 ------------------  
 -- Return  
 ------------------  
  
 return true  
end  
  
--====================================================================--  
-- BEGIN  
--====================================================================--  
  
main()  

test.lua

[code]

module(…, package.seeall)

–====================================================================–
– SCENE: [NAME]
–====================================================================–

–[[

  • Version: [1.0]
  • Made by: [name]
  • Website: [url]
  • Mail: [mail]

******************

  • INFORMATION
    ******************

  • [Your info here]

–]]

new = function ()


– Groups

local localGroup = display.newGroup()

local halfW = display.contentCenterX
local halfH = display.contentCenterY

– Background image
local bkg = display.newImage( “paper_bkg.png”, true )
bkg.x = halfW
bkg.y = halfH

– Image that the x-ray reveals. In display object rendering,
– this is above the background. The mask effect makes it look
– underneath
local image = display.newImage( “grid.png”, true )
image.alpha = 0.7

– The mask that creates the X-ray effect.
local mask = graphics.newMask( “circlemask.png” )
image:setMask( mask )

function onTouch( event )
local t = event.target

local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )

– Spurious events can be sent to the target, e.g. the user presses
– elsewhere on the screen and then moves the finger over the target.
– To prevent this, we add this flag. Only when it’s true will “move”
– events be sent to the target.
t.isFocus = true

– Store initial position
t.x0 = event.x - t.maskX
t.y0 = event.y - t.maskY
elseif t.isFocus then
if “moved” == phase then
– Make object move (we subtract t.x0,t.y0 so that moves are
– relative to initial grab point, rather than object “snapping”).
t.maskX = event.x - t.x0
t.maskY = event.y - t.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end

return true
end
image:addEventListener( “touch”, onTouch )

– By default, the mask will limit the touch region to areas that lie inside
– both the mask and the image being masked. We can override this by setting the
– isHitTestMasked property to false, so the touch region lies inside the entire image.
image.isHitTestMasked = false

– Display instructions
local labelFont = “Zapfino”
local myLabel = display.newText( “Move circle to see behind paper”, 0, 0, labelFont, 34 )
myLabel:setTextColor( 255, 255, 255, 180 )
myLabel.x = display.contentWidth/2
myLabel.y = 200

localGroup:insert(bkg)
localGroup:insert(image)
localGroup:insert(myLabel)

return localGroup

end
[/code] [import]uid: 95998 topic_id: 24013 reply_id: 324013[/import]

Hello!

I have the same problem.

The image which has a mask on it, is being displaed masked, but not with the correct shape.
If I touch it (the masked image has a touch listener) the mask is being displaed correctly!

The strange is that, if I regen the screen (a function which repositions the masked image) it is being displayed correctly!!!

Is there a workaround?
Thank you! [import]uid: 38658 topic_id: 24013 reply_id: 120085[/import]

Hello!

I have the same problem.

The image which has a mask on it, is being displaed masked, but not with the correct shape.
If I touch it (the masked image has a touch listener) the mask is being displaed correctly!

The strange is that, if I regen the screen (a function which repositions the masked image) it is being displayed correctly!!!

Is there a workaround?
Thank you! [import]uid: 38658 topic_id: 24013 reply_id: 120085[/import]