Hi everyone
Wonder if you can help, I am trying to split the data in an array, but not in the conventionalsense and I’m not sure if it is easy to do, or even possible.
Basically, I have an array that holds simple string data pertaining to tiles, and how they should be put on the screen (it is for themain map on a game). I have made the tiles and can sort out the array with a for loop to put the appropriate tile in the appropriate place, however I also want them to face the right direction (with .rotation) rather than doing 4 different facing tiles for each tile. Here is a little demo of what im on about (written up in a few seconds, hence ‘var bob’ lol.)
var levelArray:Array = new Array();
levelArray = [1,1,1,3,2,2,3,1,1,1,1,3,2,2,2,2]
for(var i=0;i<levelArray.length;i++){
var grass:Grass = new Grass();
var water:Water = new Water();
var coastA:CoastA = new CoastA();
var bob;
if(levelArray* == 1){
bob = grass;
}else if(levelArray* == 2){
bob = water;
}else if(levelArray* == 3){
bob = coastA
}
bob.x=50*i;
bob.y=25;
addChild(bob)
}
Now What I want, ideally is to have the array hold a number and a dierection [1N,3E,2N] etc, and for the number, and the letter to be treated seperately…I just don’t now how to. Can you split the terms in an array, so that i could check the tyle type then check its derection before adding? Or am I totally barking up the wrong tree with this idea?