Ogmo Object Question


(Jason Pickering) #1

Okay so in my game I have created a lever object, then I use the node system to connect that to different objects in the level. (Not sure if this is the best way to do this, open to suggestions) here is the problem I am having though. my level loading code looks like this

// Load Lever
for each(Node in xmlData.Objects.Lever)
{
	var Lever:Ent_Lever = FP.world.create(Ent_Lever) as Ent_Lever;
	Lever.Start(Node.@x, Node.@y);
			
	for each(var ActiveNode:XML in xmlData.Objects.Lever.node)
	{
		Lever.Activate_X.push(ActiveNode.@x)
		Lever.Activate_Y.push(ActiveNode.@y)
	}
}

the problem is that when I grab the node it gives me all nodes connected to all the levers not jsut the specific one I have written so for my example XML.

<Lever id="4" x="870" y="170">
	<node x="760" y="150" />
</Lever>
<Lever id="20" x="120" y="140">
	<node x="140" y="170" />
</Lever>

would give me two nodes for each lever. any ideas on how to get just a specific lever node.


(rostok) #2

just parse the right part of xml, not the whole structure. here’s just a quick reply not really sure if it works

first one:

for each ( var ActiveNode:XML in Node.node ) 
{
// Node holds current Lever data
}

second one:

for each ( var ActiveNode:XML in xml..Lever.(@id == Node.@id).node ) 
{
...
}

even if it doesn;t work it is worth mentioning that one can filter XML with additional conditions