object:remove()

类型 函数
对象 GroupObject
display.*
返回值 DisplayObject
修订版本 版本 2024.3703
关键词 remove, 删除子对象
另请参阅 object:removeSelf()
display.remove()
组编程 (指南)

概述

通过索引号或对象引用从组中移除对象。

注意事项

语法

object:remove( indexOrChild )
indexOrChild (必填)

数字DisplayObject 从组中移除指定的显示对象,并根据需要向下移动其他元素。参数可以是子对象在组中的索引位置(数字)或子显示对象本身。

示例

-- Remove the second object from the group
display.getCurrentStage():remove( 2 )