Jump to content

Dynamic CSV Tilemap Single Row Issue - SOLVED


Recommended Posts

Hi everyone.

I am currently at the beginning phases of creating the portion of my code that will update/create my map from an algorithm I will create later. For now I am randomizing it. I am using the csv option of tilemap but running into a problem I can't figure out and I have read everything I can to no avail.

I have this in my preload():

game.load.image('worldMapTiles', '/public/assets/mapspritesheet.png');

function generateWorldTilemapCSV() {
           ** Random code here - save the space by leaving it out of post here is a copy and paste of its return from the console:

game.load.tilemap('worldMap', null, generateWorldTilemapCSV(), Phaser.Tilemap.CSV);

... and in my create()

map = game.add.tilemap('worldMap', 200, 200);

However all this does for some reason is create one 200 pixel tall row that is very wide (essentially all the tiles horizontally) as if it is ignoring the '\n'.



'mapspritesheet.png' is a simple 400x400 image ([4] 200x200 squares). I have no errors in the console. I am new so I have a feeling I am missing something obvious but I promise I have spent hours on this already before asking. Thank you in advance for your help.


UPDATE: Well it is now been multiple days and this post still has not been approved - figured it out  - the string needs to have the new line double escape like this '1\\n' which means that in my random map generator I had to add  three slashes like so: '\\\n' when appending it.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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