Jump to content

Controlling Layers CreateJS


ItsYaBoiWesley
 Share

Recommended Posts

Hey guys. I'm using CreateJS to make my javascript game.

According to the documentation, objects are layered one on top of the other, in order of their addition to the stage. To control layering, I push to multiple "layer" arrays, and add the objects from those layers. However, it isn't working! Objects that are created first are the ones on the bottom, not objects that are added first.

Here's my adding code, as you can see it adds in order of the arrays. 

  for(let a = 0; a < blockLayer.length; a++) {
    stage.addChild(blockLayer[a])
  }
  for(let b = 0; b < floorLayer.length; b++) {
    stage.addChild(floorLayer[b])
  }
  for(let c = 0; c < entityLayer.length; c++) {
    stage.addChild(entityLayer[c])
  }
  for(let d = 0; d < lightLayer.length; d++) {
    stage.addChild(lightLayer[d])
  }
  for(let e = 0; e < uiLayer.length; e++) {
    stage.addChild(uiLayer[e])
  }
  stage.update();

  blockLayer = floorLayer = entityLayer = lightLayer = uiLayer = [];

Anyone with experience in CreateJS? Help would be really appreciated! :D

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...