类型 函数 库 display.* 版本 Release 2024.3703 关键词 组、容器 另请参见 使用容器 (指南)
容器是特殊类型的组,其中子级被容器的边界剪切(遮蔽)。
有关更多信息,请参见 使用容器 指南。
display.newContainer( [parent,] width, height )
容器对象使用遮罩创建,并且嵌套遮罩的限制为 3。因此,当将其他遮蔽对象插入到容器中时,必须小心。利用遮罩的显示对象包括 display.newText、display.newEmbossedText、widget.newScrollView、widget.newTableView、其他容器,以及任何其他遮蔽图像、遮蔽矢量对象或遮蔽显示组。例如,容器内(一个遮罩)的文本对象(一个遮罩)内再有一个容器(一个遮罩),将达到 3 个嵌套遮罩的限制,但不会超过。
-- 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} )