Jump to content

Occlusion culling with a tilemap


devx123x
 Share

Recommended Posts

I have a tilemap with two layers. How can I make sure only the tiles that are visible are being rendered? If a tile on the first layer is covered completely by a tile of the second layer, I don't want to render it. But some tiles on the second layer do not completely cover the tile below them. Anyone have some code samples?

Link to comment
Share on other sites

I use multiple layers to do that, All you need to do is just hide it using layer1.visible = false;
My code:

if(player.body.x > 5500 && player.body.y < 6720) {
    world_Map_2_layer.visible = true;
    if(player.body.x > 6900) {
      world_Map_1_layer.visible = false;
    }
}

if(player.body.x < 6900) {
  world_Map_1_layer.visible = true;
  if(player.body.x < 5650) {
    world_Map_2_layer.visible = false;
  }
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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