Jump to content

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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