Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Put container in a container?


Legomite
 Share

Recommended Posts

I have a game with a world that is split into multiple sections, each section has a container of their own.

(I'm not really sure how camera works)

It appears that from a earlier test in a older game I made, the camera makes the container that it is added to, moves. Everything else out of the container is static. Is it possible to make the sections (containers) put into 1 large container that the camera is added to? Is there another way? When I try it, all it does is freeze the game. I need help!

Link to comment
Share on other sites

Yes you can put contains in another container. I always start like this:

// Create a big world layer for everything affected by the camerathis.worldLayer = new game.Container().addTo(this.stage);  this.backgroundLayer = new game.Container().addTo(this.worldLayer);  this.middlegroundLayer = new game.Container().addTo(this.worldLayer);  this.foregroundLayer = new game.Container().addTo(this.worldLayer);// Create a layer at the top for HUD and other UI elementsthis.uiLayer = new game.Container().addTo(this.stage);// Add the camera to the world layer and it works :Dcamera.addTo(this.worldLayer);
Link to comment
Share on other sites

Hahaha!

 

PixelPicoSean I use exactly the same number of containers as you :)

this.worldContainer = new game.Container().addTo(game.scene.stage);this.bg = new game.Container().addTo(this.worldContainer);this.mg = new game.Container().addTo(this.worldContainer);this.fg = new game.Container().addTo(this.worldContainer);this.ui = new game.Container().addTo(this.worldContainer);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...