Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Tilemap problems


RaptorZen64
 Share

Recommended Posts

Hello,

I've recently started playing around with Phaser but have ran into a problem. I made my tiled map in Tiled and exported it as JSON. Everything went fine, but the browser will only render the tiles that are in the first row e.g. 1 - 12. As soon as I want to render a tile that is in any other row(13,14,22,66..) it renders a blank space. I've compared my code and JSON data to the examples, and everything seems to be the same, apart from the tile height,width.. Any ides on why It only renders the first row?

 

Thank you.

 

 

Link to comment
Share on other sites

Sounds like it could be an issue parsing the tileset - paste the tileset here and that line of code if you can please.

Sure, here's the code

game.load.tilemap('map','art/tiles/level1.json',null,Phaser.Tilemap.TILED_JSON);game.load.tileset('tiles', 'art/tiles/tiles2.png',70,70);...tileset = game.add.tileset('tiles');map = game.add.tilemap('map');layer = game.add.tilemapLayer(0,0,800,600,tileset,map,0);layer.resizeWorld();

And here is the tileset, I borrowed it from the opengameart.org

https://dl.dropboxusercontent.com/u/80186523/art/tiles/tiles2.png

Link to comment
Share on other sites

The issue is that the tileset image doesn't evenly divide up. You've given it a width/height of 70x70 (which is of course correct), but the tiles don't align to a 70x70 grid. The following screen grab should help show what I mean:

 

post-1-0-22497900-1387284974.png

 

You need to trim the sheet down. Remove the blank column on the right plus the little extra padding, and remove the excess space from the bottom of the sheet too.

 

In Phaser 1.1.4 (currently in development) there are 2 new tileset values to specify the number of rows and columns to extract, but in the meantime this will resolve it.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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