I had a "problem" i want to draw a mask and use it directly on a image.
The problem is - (in the current environment) i have to save and load the drawn mask to use it it on a graphic.
Is only an example:
local function createMask(shape) local maskGroup = display.newGroup() local black = display.newRect(0,0,layoutManager.getWidth(),layoutManager.getHeight() ) black:setFillColor(0,0,0) black.anchorX = 0; black.anchorY = 0; shape.anchorX = 0.5; shape.anchorY = 0.5; shape.x = black.width / 2; shape.y = black.height / 2; maskGroup:insert(black) maskGroup:insert(shape) local TemporaryDirectory = system.TemporaryDirectory local fileName = "tempMask.png" display.save(maskGroup,fileName,TemporaryDirectory) local mask = graphics.newMask(fileName,TemporaryDirectory) maskGroup:removeSelf() return mask end
[...] local mask = createMask(display.newRect( 0, 0,200, 200)) imgEffect:setMask(mask)
This bad "solution" has sometimes effects that the mask from the rendering before is shown, cause the saving was not finished, until the loading process...
Is there an other smarter solution? Thanks!