Jump to content

One tilemap, multiple layers, each with it's own tileset?


BkoChan
 Share

Recommended Posts

I'm trying to make a construction game where the player has to place powerlines and water pipes.

I'm trying to bunch all this together in a single tilemap. What I want is a layer to draw powerlines and a layer to draw pipes but I can't figure out how to assign a tileset to a particular layer?

 

        // Create the tilemap
        oGame.tilemap = oGame.add.tilemap();

        // Add tilesets to the map
        oGame.tilemap.addTilesetImage('ts_power_lines');
        oGame.tilemap.addTilesetImage('ts_water_pipes_small');
        
        // Create tilemap layers
        oGame.tilemapLayers = {
            'waterSupply': oGame.tilemap.create('waterSupply', 40, 40, _iTileSize, _iTileSize),
            'electricSupply': oGame.tilemap.createBlankLayer('electricSupply', 40, 40, _iTileSize, _iTileSize)
        };

        // Resize the world to the correct size
        oGame.tilemapLayers.waterSupply.resizeWorld();

         // Draw tiles
        oGame.tilemap.putTile(0, 10, 6, 'waterSupply');
        oGame.tilemap.putTile(0, 10, 6, 'electricSupply');

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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