SalGnt

[1.1.6] Tileset with margins

Recommended Posts

By using a tileset that has margins I got the following error (because of the extra space given by margins I think): TileSet image dimensions do not match expected dimensions.

The JSON file was created with Tiled. Here is the code I used:

function preload() {	game.load.tilemap('piramid', 'piramid.json', null, Phaser.Tilemap.TILED_JSON);	game.load.image('tileSet', 'tiles.png', 16, 16);}function create() {	map = game.add.tilemap('piramid');	map.addTilesetImage('tileSet');	map.setCollisionByExclusion([  ], true, 'level');	levelLayer = map.createLayer('level');} 

Am I missing something?

Share this post


Link to post
Share on other sites

Hi,

Yes, mines all working. I've copied some snippets of my code below. All the names are preceded by 'this' because I've created an object to do the loading. Hopefully the idea is clear though. I think the key part is the game.load.image and the game.add.tileSetImage.

 

In game.load.image I don't define the tile size. In the map.addTilesetImage the first argument is the name of the tileset as defined in the tileset json file.Because all the details are in the json file, the tile positions in the image are picked up from there; that's what I think anyway.

 

In my preload:

game.load.tilemap(this.mapId, this.jsonUrl, null, Phaser.Tilemap.TILED_JSON);game.load.image(this.imageId, this.imageUrl);

In my create:

this.map = game.add.tilemap(this.mapId);this.map.addTilesetImage(this.tilesetName, this.imageId);this.layer = this.map.createLayer(this.layerName);this.layer.resizeWorld();

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.