I was using a small portion of the TileLayer import code, testing against a csv export from Tiled and I ran into some issues -
the string input comes from the tmx with all kinds of extra newlines/spaces
the row items are parsed by ,, but because of the new line split there is an additional one, leading to a "" at the end of the row array, and this, it get's pushed into the array as well making the resulting tilemap offset and "broken"
I would make a pull request if need be, but it's simple really so!
Before : (wrong)
After : (expected)
You can see the printed output here, showing the blanks :
//before
private static function csvToArray(input:String):Array<Int> {
var result:Array<Int> = new Array<Int>();
var rows:Array<String> = input.split("\n");
var row:String;
for (row in rows){
if (row == "") continue;
var resultRow:Array<Int> = new Array<Int>();
var entries:Array<String> = row.split(",");
var entry:String;
for (entry in entries)
result.push(Std.parseInt(entry));
}
return result;
}
//after
private static function csvToArray(input:String):Array<Int> {
var result:Array<Int> = new Array<Int>();
var rows:Array<String> = StringTools.trim(input).split("\n");
var row:String;
for (row in rows){
if (row == "") continue;
var resultRow:Array<Int> = new Array<Int>();
var entries:Array<String> = row.split(",");
var entry:String;
for (entry in entries) {
if(entry != "") {
result.push(Std.parseInt(entry));
}
}
}
return result;
}
I was using a small portion of the TileLayer import code, testing against a csv export from Tiled and I ran into some issues -
input
comes from the tmx with all kinds of extra newlines/spaces,
, but because of the new line split there is an additional one, leading to a "" at the end of the row array, and this, it get's pushed into the array as well making the resulting tilemap offset and "broken"I would make a pull request if need be, but it's simple really so!
Before : (wrong)
After : (expected)
You can see the printed output here, showing the blanks :