cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Non-collision tile layers aren't showing up. #68

Closed lendrick closed 10 years ago

lendrick commented 10 years ago

When I try to make a multi-layered 2d tile map, the only layer that draws on the screen is the collision layer. The other layers either aren't loading or aren't being drawn. Here's the code that fails:

  console.log("bg1");
  stage.insert(new Q.TileLayer({ 
    dataAsset: 'level.tmx', 
    sheet: 'tiles', 
    layerIndex: 'Background',
    tileW: 70,
    tileH: 70
  }));

  console.log("coll");
  stage.collisionLayer(new Q.TileLayer({ 
    dataAsset: 'level.tmx', 
    sheet: 'tiles', 
    layerIndex: 'Tile Layer 1',
    tileW: 70,
    tileH: 70
  }));
  var player = stage.insert(new Q.Player({ x: 700, y: 5000 }));

  console.log("bg2");
  stage.insert(new Q.TileLayer({ 
    dataAsset: 'level.tmx', 
    sheet: 'tiles', 
    layerIndex: 'Background 2',
    tileW: 70,
    tileH: 70
  }));

Note that the player sprite inserts just fine. Also note that this bug is only showing up in the latest git version and not in 0.1.5. Please let me know if there's any more information that I can provide.

lendrick commented 10 years ago

Incidentally, appending this code to the end of markSprites() fixes the issue, but I'm not sure if it's the right way to fix it:

      for(i = 0; i < this.items.length; i++) {
        if(this.items[i] instanceof Q.TileLayer) {
          this.items[i].mark = time;
        }
      }
cykod commented 10 years ago

This should be fixed in 0.2.0 as tile layers are set to renderAlways - please re-open if it's not