mattasaurus

Multiple tilesets in a single Tiled layer?

Recommended Posts

In Tiled (1.1.3) you can make a layer that includes multiple different embedded tilesets.

The resulting JSON has an array in the tilesets property. See complete example https://pastebin.com/jYP4buQc .

I can't get this to load in Phaser. I've tried several things, but anything after the first tileset throws an error one way or another. Here's the latest attempt:

        function preload() {
            this.load.tilemapTiledJSON('map', '/maps/phaserTest.json');
            this.load.image('phaserTestImg', '/maps/phaserTest.png');
            this.load.image('Door0', '/maps/Door0.png');
            this.load.image('Floor', '/maps/Floor.png');
            this.load.image('Wall', '/maps/Wall.png');
        }

        function create() {
            var map = this.add.tilemap('map');
            var tileset = map.addTilesetImage('Wall', undefined, 16, 16, 0, 0, 1);
            var tileset2 = map.addTilesetImage('Door0', undefined, 16, 16, 0, 0, 2);
            var tileset3 = map.addTilesetImage('Floor', undefined, 16, 16, 0, 0, 3);
            var layer = map.createStaticLayer(0, tileset);
            var layer2 = map.createStaticLayer(1, tileset2);
            var layer3 = map.createStaticLayer(2, tileset3);

            //debugger;
            var graphics = this.add.graphics();

            //[...]

(I've also tried using map.createStaticLayer with the string name of the layer from Tiled JSON, this is just the latest failed experiment.)

My guess is this isn't supported and I have to create my maps differently in Tiled, but I am brand new to Phaser and I might just be missing something obvious.

Back in 2013, Rich seemed to say it wasn't supported

but 2013 is quite a long time ago and I know a lot has changed with tileset handling since then.

So my questions:

1) Can you make a map in Tiled that has multiple (embedded) tilesets in a single layer, and use that JSON from Phaser successfully? If so, can I get a hint on how to do this correctly?

2) If this isn't supported, what is the best alternate approach in Phaser 3? Two things that occur to me are making a Tiled map that has a separate layer for each tileset, or combining lots of little tilesets together into a mechagodzilla tileset so I can lay out a whole bunch of features in a single layer. Or something different. Opinions?

 

Share this post


Link to post
Share on other sites

@PixelPicoSean Not really what I meant. In Tiled (tile editor) you can flip and rotate individual tiles. When I now import that into Phaser 3 the rotation and flipping of those tiles is not applied. Don't spend any time figuring this out though. I can read the code  myself and find out what's wrong.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.