1 decade ago by erinlaura
I'm working on a game that spawns entities from an XML sheet. It iterates through the xml nodes, pulls out the variables, and then spawns the entity. This works great, except that it doesn't accept variables from an xml as the x or y position. It takes variables from the main.js file as x and y positions though fine.
Normally it will load all of my entities, and then they disappear and the browers crashes. What is going on?
//loop for spawning entities for (x = 0 ; x <segment[this.segment_num].getElementsByTagName(child_node).length; x ++) { var entity_data = segment[this.segment_num].getElementsByTagName(child_node)[x]; for (i = 0 ; i < entity_data.children.length; i ++) { new_entity[entity_data.children[i].nodeName] = entity_data.children[i].textContent; //console.log("entity node name: " + entity_data1.children[i].nodeName + "node value: " + entity_data1.children[i].textContent); } ig.game.spawnEntity(EntityLayer,new_entity["x"], new_entity["y"], { zIndex:new_entity["z"], animSheet: new ig.AnimationSheet(new_entity["image"],new_entity["width"], new_entity["height"])}); } //xml that is being imported <entities> <entity> <x>200</x> <y>50</y> <z>2</z> <height>416</height> <width>700</width> <image>media/mountain2.png</image> </entity> <entity> <x>10</x> <y>10</y> <z>3</z> <height>351</height> <width>1200</width> <image>media/mountain1.png</image> </entity> <entity> <x>10</x> <y>10</y> <z>4</z> <height>100</height> <width>152</width> <image>media/hut.png</image> </entity> <entity> <x>10</x> <y>10</y> <z>5</z> <height>150</height> <width>100</width> <image>media/princess.png</image> </entity> </entities>
Normally it will load all of my entities, and then they disappear and the browers crashes. What is going on?