composer.stage

类型 DisplayObject
composer.*
返回值 DisplayObject
修订版 发行版 2024.3703
关键字 composer、场景、stage、组

概述

返回对插入所有场景视图的顶级 Composer 显示组的引用。这可以看作“Composer 场景层”,如果你需要在所有 Composer 场景之上或之下放置显示对象,即使在过渡效果期间也是如此,则它非常有用。例如

语法

composer.stage

示例

local composer = require( "composer" )

-- Create a background which should appear behind all scenes
local background = display.newImage( "bg.png" )
 
-- Create a "health meter" image which should appear above all scenes
local meter = display.newImage( "health100.png" )
meter.anchorX = 0
meter.anchorY = 1
meter.x, meter.y = 20, display.contentHeight-20

-- Sort everything in the correct z-index order
local stage = display.getCurrentStage()
stage:insert( background )
stage:insert( composer.stage )
stage:insert( meter )

-- Open the initial scene
composer.gotoScene( "scene1", "fade", 800 )