Hi to all and excuse me for my english
I have the code:
function Diomautils.applyMaskFromPolygon(object, polygon, maskName) – thanks to http://ragdogstudios.com
--we use these to scale down the mask so that it looks exactly the same on any device
local pixelWidth, pixelHeight;
local contentWidth, contentHeight = display.contentWidth-(display.screenOriginX*2), display.contentHeight-(display.screenOriginY*2);
if contentWidth > contentHeight then
pixelWidth = display.pixelHeight;
pixelHeight = display.pixelWidth;
else
pixelWidth = display.pixelWidth;
pixelHeight = display.pixelHeight;
end
local maskGroup = display.newGroup();
--create a rect with width and height higher than polygon and rounded up to 2^)
local rectWidth, rectHeight = 1, 1;
while (rectWidth < polygon.contentWidth) do
rectWidth = rectWidth*2;
end
while (rectHeight < polygon.contentHeight) do
rectHeight = rectHeight*2;
end
local blackRect = display.newRect(maskGroup, 0, 0, rectWidth, rectHeight);
blackRect:setFillColor(0, 0, 0, 1);
maskGroup:insert(blackRect)
maskGroup:insert(polygon);
polygon.x, polygon.y = 0, 0;
polygon:setFillColor(1, 1, 1, 1);
maskGroup.x, maskGroup.y = display.contentCenterX, display.contentCenterY;
display.save(maskGroup, {filename = maskName or “mask.jpg”, baseDir = system.DocumentsDirectory, isFullResolution = true});
local mask = graphics.newMask(maskName or “mask.jpg”, system.DocumentsDirectory);
object:setMask(mask);
--here we scale down the mask to make it consistent across devices
object.maskScaleX = contentWidth/pixelWidth;
object.maskScaleY = object.maskScaleX;
maskGroup:removeSelf();
end
that can mask a group dinamically. So the display.save() not save correctly! On the saved image there isn’t the blackRect!!! Is a known simulator issue or is it my bad?
Thanks you very much!!!