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

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