Jump to content

How do I load tile map with phaser 3


mirvine
 Share

Recommended Posts

Hi,

I created a simple tilemap with tiled, and I'm trying to load it. The code and files can be seen here:

https://codesandbox.io/s/qqq47wqv3w

I'm not getting any errors in the console, but the canvas is just a black square. Any ideas what I am doing wrong?

      var game = new Phaser.Game(config);

      function preload() {
        this.load.image("tiles", "assets/tiles.png");
        this.load.tilemapTiledJSON("World", "assets/tilemap2.json");
      }
      function create() {
        this.map = this.add.tilemap("World");
        var tileset = this.map.addTilesetImage("tiles", "tiles");
        his.backgroundLayer = this.map.createStaticLayer("World", tileset);
      }

The timemap.json from Tiles is below:

{ "height":100,
 "infinite":false,
 "layers":[
        {
         "data":[3, 3, 3, 3, 3, 3, 3, 3, ...[data omitted]..., 3, 3],
         "height":100,
         "id":1,
         "name":"World",
         "opacity":1,
         "type":"tilelayer",
         "visible":true,
         "width":100,
         "x":0,
         "y":0
        }],
 "nextlayerid":2,
 "nextobjectid":1,
 "orientation":"orthogonal",
 "renderorder":"right-down",
 "tiledversion":"1.2.1",
 "tileheight":8,
 "tilesets":[
        {
         "columns":8,
         "firstgid":1,
         "image":"tiles.png",
         "imageheight":48,
         "imagewidth":64,
         "margin":0,
         "name":"tiles",
         "spacing":0,
         "tilecount":48,
         "tileheight":8,
         "tilewidth":8
        }],
 "tilewidth":8,
 "type":"map",
 "version":1.2,
 "width":100
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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