Difference between revisions of "The Stage"

From GiderosMobile
(Created page with "The scene tree is the hierarchy of all graphical objects currently displayed and this hierarchy needs a root. The root of the scene tree is an instance of the Stage class whic...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
  
 
- Create a Sprite object
 
- Create a Sprite object
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
local mySprite = Sprite.new()
 
local mySprite = Sprite.new()
</source>
+
</syntaxhighlight>
  
 
- Add this sprite to the stage:
 
- Add this sprite to the stage:
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
stage:addChild(mySprite)
 
stage:addChild(mySprite)
</source>
+
</syntaxhighlight>

Latest revision as of 14:33, 13 July 2023

The scene tree is the hierarchy of all graphical objects currently displayed and this hierarchy needs a root. The root of the scene tree is an instance of the Stage class which is automatically created and set as a global variable when Gideros starts. You can access this global variable with the name stage.

When Gideros starts, the display list hierarchy contains one item (the global Stage instance) only and we can add more:

- Create a Sprite object

local mySprite = Sprite.new()

- Add this sprite to the stage:

stage:addChild(mySprite)