类型 函数 库 display.* 返回值 显示对象 (DisplayObject) 修订 版本 2024.3703 关键词 组,舞台,屏幕 另请参阅 display.currentStage 组编程 (指南)
返回对当前舞台对象的引用,该对象是所有显示对象和组的父组。目前,Corona 只有一个舞台实例,因此此函数始终返回对同一对象的引用。
display.getCurrentStage()
-- Used in conjunction with a touch event listener and the ":setFocus()" method function object:touch( event ) if event.phase == "began" then -- Get stage and call ":setFocus()" method local stage = display.getCurrentStage() stage:setFocus( self ) self.isFocus = true elseif self.isFocus then if event.phase == "ended" or event.phase == "cancelled" then local stage = display.getCurrentStage() stage:setFocus( nil ) end end return true end
-- Ungroup an object from its current parent group by inserting it into the top-level "stage" group local g = display.newGroup() local obj = display.newImage( "image.png" ) g:insert( obj ) local stage = display.getCurrentStage() -- Ungroup object by inserting into top-level stage group stage:insert( obj ) -- Object no longer belongs to the "g" group