Type Function
Library display.*
Revision Current Public Release (2014.2393)
Keywords groups, container
See also Container Programming Guide


Containers are a special kind of group in which the children are clipped (masked) by the bounds of the container.

See Container Programming Guide for more information.


display.newContainer( [parent, ] width, height )


Container objects are created using a mask. Since there is a masking nesting limit of three on all platforms, care must be taken when inserting other masked objects into containers. Other masked objects include: another container, display.newText, display.newEmbossedText, masked image, widget.newScrollView and widget.newTableView.


-- Create a container
local container = display.newContainer( 128, 128 )

-- Create an image
local bkgd = display.newImage( "aquariumbackgroundIPhone.jpg" )
-- Insert the image into the container
container:insert( bkgd, true )
-- Center the container in the display area
container:translate( display.contentWidth*0.5, display.contentHeight*0.5 )

-- Transition (rotate) the container
transition.to( container, { rotation=360, transition=easing.inOutExpo} )