Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Support for something like layers? — Gideros Forum

Support for something like layers?

MikeHartMikeHart Guru
edited December 2011 in General questions
Hi,

I just had a look at the API documentation. There is the stage, but I think it is only one general container for all objects.

The question I have atm. and before I can test this myself is, how can you layer images in the right order. Something like

-draw background first
-then the game objects
-on top, draw UI elements

Is this supported?

Comments

  • atilimatilim Maintainer
    edited December 2011
    You can add 3 sprites in any order you want:
    background = Sprite.new()
    game = Sprite.new()
    ui = Sprite.new()
     
    stage:addChild(background)
    stage:addChild(game)
    stage:addChild(ui)
    And then add/remove children to background, game and ui sprites. So that background (and its children) is always at back and UI is always at front.

    But it's better to derive your own classes from Sprite and then add these. So that you can integrate your own game/ui logic to these Sprites:
    Game = gideros.class(Sprite)
    UI = gideros.class(Sprite)
     
    game = Game.new()
    ui = UI.new()
     
    stage:addChild(game)
    stage:addChild(ui)

    Likes: MikeHart, Averett

    +1 -1 (+2 / -0 )Share on Facebook
  • NICE!!! That is a very clever approach! Thanks for the explanation.
Sign In or Register to comment.