This is for loading maps made with OGMO Editor 2. For loading maps made with OGMO Editor 3, use FlxOgmo3Loader

Constructor

new(LevelData:Dynamic)

Creates a new instance of FlxOgmoLoader and prepares the XML level data to be loaded. This object can either be contained or ovewritten.

IMPORTANT: Tile layers must have the Export Mode set to "CSV". First tile in spritesheet must be blank or debug. It will never get drawn so don't place them in Ogmo! (This is needed to support many other editors that use index 0 as empty)

Parameters:

LevelData

A String or Class representing the location of xml level data.

Variables

Methods

inlinegetProperty(name:String):String

Allows for loading of level properties specified in Ogmo editor. Useful for getting properties without having to manually edit the FlxOgmoLoader Returns a String that will need to be parsed

Parameters:

name

A string that corresponds to the property to be accessed

@:value({ EntityLayer : "entities" })loadEntities(EntityLoadCallback:(String, Xml) ‑> Void, EntityLayer:String = "entities"):Void

Parse every entity in the specified layer and call a function that will spawn game objects based on their name. Optional data can be read from the xml object, here's an example that reads the position of an object:

public function loadEntity(type:String, data:Xml):Void
{
    switch (type.toLowerCase())
    {
        case "player":
            player.x = Std.parseFloat(data.get("x"));
            player.y = Std.parseFloat(data.get("y"));
        default:
            throw 'Unrecognized actor type $type';
    }
}

Parameters:

EntityLoadCallback

A function with the signature (name:String, data:Xml):Void and spawns entities based on their name.

EntityLayer

The name of the layer the entities are stored in Ogmo editor. Usually "entities" or "actors".

@:value({ RectLayer : "rectangles" })loadRectangles(RectLoadCallback:FlxRect ‑> Void, RectLayer:String = "rectangles"):Void

Parse every 'rect' in the specified layer and call a function to do something based on each rectangle. Useful for setting up zones or regions in your game that can be filled in procedurally.

Parameters:

RectLoadCallback

A function that takes in the Rectangle object and returns Void.

RectLayer

The name of the layer which contains 'rect' objects.

@:value({ TileLayer : "tiles", TileHeight : 16, TileWidth : 16 })loadTilemap(TileGraphic:FlxTilemapGraphicAsset, TileWidth:Int = 16, TileHeight:Int = 16, TileLayer:String = "tiles", ?tilemap:FlxTilemap):FlxTilemap

Load a Tilemap. Tile layers must have the Export Mode set to "CSV". Collision with entities should be handled with the reference returned from this function. Here's a tip:

IMPORTANT: Always collide the map with objects, not the other way around. This prevents odd collision errors (collision separation code off by 1 px):

FlxG.collide(map, obj, notifyCallback);

Parameters:

TileGraphic

A String or Class representing the location of the image asset for the tilemap.

TileWidth

The width of each individual tile.

TileHeight

The height of each individual tile.

TileLayer

The name of the layer the tilemap data is stored in Ogmo editor, usually "tiles" or "stage".

tilemap

(optional) A tilemap to load tilemap data into. If not specified, new FlxTilemap instance is created.

Returns:

A FlxTilemap, where you can collide your entities against.