object.maskY

Type Number
Object DisplayObject
Library display.*
Revision Release 2022.3683
Keywords mask, y, mask position, image mask, masking, clipping, bit mask
See also object.maskX
object:setMask()

Overview

Retrieve or set the y position of the mask applied to the display object using object:setMask().

Example

-- This example moves the image mask to the position where the user moves their finger

-- Image to be masked
local image = display.newImageRect( "image.png", 768, 1024 )
image:translate( halfW, halfH )
 
-- Mask
local mask = graphics.newMask( "circlemask.png" )
image:setMask( mask )
 
function onTouch( event )

    local t = event.target
    
    if ( event.phase == "moved" ) then
        t.maskX = event.x
        t.maskY = event.y
    end
end
 
image:addEventListener( "touch", onTouch )