Hello Kirupa community
Im having a big problem in my game. Im thinkin on it almost a entire month, just to figures whats happening. I isolated the code on another fla, to try to get it, but I have no clues.
The olny thing I know is this: I try to set only some tiles to be doors, but a lot of other tiles are set as door objects too.
This problem is not easy to explain. Heres the isolated code:
//first, I will create pseudo-tile objects, because in the original game, tiles are set by a xml.
var aaaTiles:Array = [];
var tilez:Object = new Object();
var tilez2:Object = new Object();
var tilez3:Object = new Object();
var tilez4:Object = new Object();
var tilez5:Object = new Object();
tilez.door = false;
tilez2.door = false;
tilez3.door = false;
tilez4.door = false;
tilez5.door = false;
aaaTiles.push(tilez);
aaaTiles.push(tilez2);
aaaTiles.push(tilez3);
aaaTiles.push(tilez4);
aaaTiles.push(tilez5);
//
//all the tile objects have door property set to false
//
function build_XmlMap(mapNamezz):Void {
//
//here I will build the world by a array from xml>>>
//
System.useCodepage = true;
var xmlMap:XML = new XML();
var fMap:Array = [];
xmlMap.ignoreWhite = true;
xmlMap.load(mapNamezz);
xmlMap.onLoad = function() {
mainDados = this.firstChild.childNodes;
len = mainDados.length;
//cutting the string to fit a 2d map…
var hSplit:Array = mainDados[0].attributes.map.split(“ªª”);
for (i=0; i<=(hSplit.length-1); i++) {
fMap* = hSplit*.split(",");
}
//add tiles
for (i=0; i<=(fMap.length-1); i++) {
for (l=0; l<=(fMap[0].length-1); l++) {
//
//now the interesting part: if the tile has door property, assign to it door true
//
zMap = fMap*[l].split(“ºº”);
fMap*[l] = aaaTiles[zMap[0]];
for (zz=0; zz<zMap.length; zz++) {
if (zMap*.substr(0, 2) == “do”) {
fMap*[l].door = true;
trace(“new door added”)
}
}
}
}
//buildMap(fMap);
//now I will check to see how doors was assigned
for (v=0; v<=fMap.length; v++) {
for (b=0; b<=fMap[0].length; b++) {
if (fMap[v]**.door) {
trace(“yes we got a door___:”+v+"_"+b);
}
}
}
};
}
build_XmlMap(“pak/map_01.xml”);
////////////////////////////////////////////////////////////////////////////////////
What shows in trace screen:
new door added
new door added
yes we got a door___:1_3
yes we got a door___:1_4
yes we got a door___:1_5
yes we got a door___:1_6
yes we got a door___:1_7
yes we got a door___:1_8
yes we got a door___:1_9
yes we got a door___:1_10
yes we got a door___:1_11
yes we got a door___:1_12
yes we got a door___:1_13
yes we got a door___:1_14
yes we got a door___:1_15
Two doors exist. A lot of more doors was created, why?
Thanks for reading, hard task.