object.maskX

Type Number
Object DisplayObject
Library display.*
Revision Current Public Release (2017.3068)
Keywords mask, x, mask position, image mask, masking, clipping, bit mask
See also object.maskY
object:setMask()

Overview

Retrieve or set the x 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 )