Available since

2.8.0

.

Constructor

new(projectData:String, levelData:String)

Creates a new instance of FlxOgmo3Loader and prepares the level and project data to be used in other methods

Parameters:

projectData

The path to your project data (.ogmo).

levelData

The path to your level data (.json).

Methods

getLevelValue(value:String):Dynamic

Get a custom value for the loaded level. Returns null if no value is present.

@:value({ decalLayer : "decals" })loadDecals(decalLayer:String = "decals", decalsPath:String):FlxGroup

Loads every decal in a decal layer into a FlxGroup.

IMPORTANT: All decals must be included in one directory!

Parameters:

decalLayer

The name of the layer the decals are stored in Ogmo editor. Usually "decals".

decalsPath

The path to the directory in which your decal assets are stored.

@:value({ entityLayer : "entities" })loadEntities(entityLoadCallback:EntityData ‑> Void, entityLayer:String = "entities"):Void

Parse every entity in the specified layer and call a function that will spawn game objects based on its entity data. Here's an example that reads the position of an object:

function loadEntity(entity:EntityData)
{
    switch (entity.name)
    {
        case "player":
            player.x = entity.x;
            player.y = entity.y;
            player.custom_value = entity.values.custom_value;
        default:
            throw 'Unrecognized actor type ${entity.name}';
    }
}

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({ gridLayer : "grid" })loadGridMap(gridLayer:String = "grid"):Map<String, Array<FlxPoint>>

Loads a Map of FlxPoint arrays from a grid layer. For example:

var gridData = myOgmoData.loadGridMap('my grid layer');
for (point in gridData['e'])
    addSpawnPoint(point.x, point.y);

@:value({ tileLayer : "tiles" })loadTilemap(tileGraphic:FlxTilemapGraphicAsset, tileLayer:String = "tiles", ?tilemap:FlxTilemap):FlxTilemap

Load a Tilemap. Collision with entities should be handled with the reference returned from this function.

IMPORTANT: Tile layers must export using IDs, not Coords!

Parameters:

tileGraphic

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

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.

@:value({ tileLayer : "tiles" })loadTilemapExt(tileGraphic:FlxTilemapGraphicAsset, tileLayer:String = "tiles", ?tilemap:FlxTilemapExt):FlxTilemapExt

Load a FlxTilemapExt, which supports additional features such as flipped and rotated tiles. Collision with entities should be handled with the reference returned from this function.

IMPORTANT: Tile layers must export using IDs, not Coords!

Parameters:

tileGraphic

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

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 FlxTilemapExt instance is created.

Returns:

A FlxTilemapExt, where you can collide your entities against.

Available since

2.10.0

.