G
G
Grigory Zhdanov2015-04-26 16:04:36
JSON
Grigory Zhdanov, 2015-04-26 16:04:36

How to include a tile map in phaser.js?

How to properly connect a tile map in phaser.js?
There is a code:

var game = new Phaser.Game(600, 450, Phaser.AUTO, 'game-field', { preload: preload, create: create, update: update });

function preload() {
  game.load.image('tiles', '../assets/tilea2.png');
  game.load.tilemap('tilemap', '../assets/map.json', null, Phaser.Tilemap.TILED_JSON);
}

function create() {
  game.stage.backgroundColor = '#787878';
    map = game.add.tilemap('tilemap');
    map.addTilesetImage('tilea2.png', 'tiles');
    layer = map.createLayer('world');
    layer.resizeWorld();
}

function update() {
}

Unfortunately it doesn't work. Please tell me what could be wrong.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question