I’m trying to set a mask on a container, because I need some particles to show only behind some features of my scene.
Here’s the mask image: http://i.imgur.com/N5BiUZB.png
It’s 240x92 in size.
self.waterContainer = self:addToScene(display.newContainer(240, 92)) self.waterContainer.anchorChildren = false self.waterContainer.anchorX, self.waterContainer.anchorY = 0, 0 self.waterContainer.x, self.waterContainer.y = 165, 249 self.waterContainer:setMask(graphics.newMask("mask\_sink.png")) --self.waterContainer.maskX, self.waterContainer.maskY = 0,0 --self.waterContainer.maskX, self.waterContainer.maskY = self.waterContainer.x, self.waterContainer.y
The commented lines were things that I tried to make this work.
So, I tried adding a rectangle to try the mask out since it wasn’t working for me, like this:
self.waterContainer:insert(game.ui.newRect(0, 0, 240, 92, {0,0,0}))
and this is the result: http://i.imgur.com/jDKLyNL.png
Without the mask, this is the result: http://i.imgur.com/GmbSy1Q.png
That is the correct area that should be covered by the container, but the mask is screwing it up for some reason.
Can someone tell me if I’m doing something wrong here?
By the way, the newRect method I use above is defined like this:
function ui.newRect(x, y, w, h, color, touch) local rect = display.newRect(x, y, w, h) rect.alpha = 1 if color then rect:setFillColor(color[1], color[2], color[3]) if #color == 4 then rect.alpha = color[4] end end rect.anchorX, rect.anchorY = 0, 0 rect.x, rect.y = x, y if touch then rect.isHitTestable = true rect:addEventListener("touch", touch) end return rect end
Any help is appreciated.
Thanks,
George