Help with converting an XML into a 2D level (Actionscript 3.0)

Posted by inzombiak on Game Development See other posts from Game Development or by inzombiak
Published on 2012-06-23T18:30:01Z Indexed on 2012/06/23 21:25 UTC
Read the original article Hit count: 275

I'm making a little platformer and wanted to use Ogmo to create my level. I've gotten everything to work except the level that my code generates is not the same as what I see in Ogmo. I've checked the array and it fits with the level in Ogmo, but when I loop through it with my code I get the wrong thing. I've included my code for creating the level as well as an image of what I get and what I'm supposed to get.

EDIT: I tried to add it, but I couldn't get it to display properly

Also, if any of you know of better level editors please let me know.

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("Level1.oel"));
        function LoadXML(e:Event):void
        {
            levelXML = new XML(e.target.data);
            xmlFilter = levelXML.*
            for each (var levelTest:XML in levelXML.*)
            {
                crack = levelTest;
            }
            levelArray = crack.split('');
            trace(levelArray);
            count = 0;
            for(i = 0; i <= 23; i++)
            {
                for(j = 0; j <= 35; j++)
                {
                    if(levelArray[i*36+j] == 1)
                    {
                        block = new Platform;
                        s.addChild(block);
                        block.x = j*20;
                        block.y = i*20;
                        count++;
                        trace(i);
                        trace(block.x);
                        trace(j);
                        trace(block.y);
                    }
                }
            }
            trace(count);

enter image description here Left: What I get, Right: What I should get

© Game Development or respective owner

Related posts about flash

Related posts about actionscript-3