How to get the "length value" from a CSV file?

25 views
Skip to first unread message

JustGabe

unread,
Nov 16, 2015, 10:05:23 PM11/16/15
to HaxeFlixel


So thanks to this two simple lines, it's possible to make a whole map easily:
currentMap = new FlxTilemap();
currentMap.loadMap(Assets.getText("assets/data/BattleMap01.txt"), "assets/images/World.png", TS, TS, 0, 0);
However, in order to make an isometric map based on the values of this cartesian map, I need the lenght of the "i" and the "j" rows of that particular text, but I have no idea how.

Jeru Sanders

unread,
Nov 18, 2015, 3:31:55 PM11/18/15
to haxef...@googlegroups.com
Not sure what exactly you mean, but getting the width and height of the CSV can be done with something like this:

var t:String = Assets.getText("...");
var lines:Array<String> = t.split("\n");
var firstLine:Array<String> = lines[0].split(",");


var height:Int lines.length;
var width:Int firstLine.length;

JustGabe

unread,
Nov 18, 2015, 10:10:54 PM11/18/15
to HaxeFlixel
That's EXACTLY what I needed! Thank you!
Reply all
Reply to author
Forward
0 new messages