Type Function Library display.* Return value DisplayObject Revision 2017.3060 Keywords group, stage, screen See also display.currentStage Group Programming (guide)
Returns a reference to the current stage object, which is the parent group for all display objects and groups. Currently, Corona has a single stage instance, so this function always returns a reference to the same object.
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