Jump to content

How to use tiled map editor with phaser?


longzma11
 Share

Recommended Posts

Here's the example provided on the Phaser website.

 

 

The first step is to make a map in Tiled and export it as a json file.

Next, put the json file and the spritesheet used to create the map in assets folder of your Phaser game.

 

Then, in your games preload function, add these lines changing the parameters to suit your values:

game.load.tilemap('mapName', 'assets/tilemap.json', null, Phaser.Tilemap.TILED_JSON);game.load.image('sprites', 'assets/sprites.png');

Then in your create function you'll need to add these lines to create the map in the game:

    map = game.add.tilemap('mapName');    map.addTilesetImage('sprites', 'sprites');    layer = map.createLayer('LayerName');    layer.resizeWorld();

 

Make sure you pay attention to your map and layer names while making the map! Make sure your code references the correct map name and layer name. This is a common newbie error (I know because I had that problem myself :P).

 

If you need a tutorial on how to make maps in Tiled, check out this.

Link to comment
Share on other sites

  • 10 months later...
 Share

  • Recently Browsing   0 members

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