me.levelDirector

a level manager object
once ressources loaded, the level director contains all references of defined levels
There is no constructor function for me.levelDirector, this is a static object

Methods

static getCurrentLevel() → {me.TMXTileMap}

return the current level definition. for a reference to the live instantiated level, rather use the container in which it was loaded (e.g. me.game.world)

Returns:
me.TMXTileMap

static getCurrentLevelId() → {String}

return the current level id

Returns:
String

static levelCount()

return the amount of level preloaded

static loadLevel(level, optionsopt)

load a level into the game manager
(will also create all level defined entities, etc..)

Parameters:
Name Type Attributes Description
level String

level id

options Object <optional>

additional optional parameters

Properties
Name Type Attributes Default Description
container me.Container <optional>
me.game.world

container in which to load the specified level

onLoaded function <optional>
me.game.onLevelLoaded

callback for when the level is fully loaded

flatten boolean <optional>
me.game.mergeGroup

if true, flatten all objects into the given container

setViewportBounds boolean <optional>
true

if true, set the viewport bounds to the map size

Example
// the game assets to be be preloaded
// TMX maps
var resources = [
    {name: "a4_level1",   type: "tmx",   src: "data/level/a4_level1.tmx"},
    {name: "a4_level2",   type: "tmx",   src: "data/level/a4_level2.tmx"},
    {name: "a4_level3",   type: "tmx",   src: "data/level/a4_level3.tmx"},
    // ...
];

// ...

// load a level into the game world
me.levelDirector.loadLevel("a4_level1");
...
...
// load a level into a specific container
var levelContainer = new me.Container();
me.levelDirector.loadLevel("a4_level2", {container:levelContainer});
// add a simple transformation
levelContainer.currentTransform.translate(levelContainer.width / 2, levelContainer.height / 2 );
levelContainer.currentTransform.rotate(0.05);
levelContainer.currentTransform.translate(-levelContainer.width / 2, -levelContainer.height / 2 );
// add it to the game world
me.game.world.addChild(levelContainer);

static nextLevel(optionsopt)

load the next level

Parameters:
Name Type Attributes Description
options Object <optional>

additional optional parameters

Properties
Name Type Attributes Default Description
container me.Container <optional>
me.game.world

container in which to load the specified level

onLoaded function <optional>
me.game.onLevelLoaded

callback for when the level is fully loaded

flatten boolean <optional>
me.game.mergeGroup

if true, flatten all objects into the given container

static previousLevel(optionsopt)

load the previous level

Parameters:
Name Type Attributes Description
options Object <optional>

additional optional parameters

Properties
Name Type Attributes Default Description
container me.Container <optional>
me.game.world

container in which to load the specified level

onLoaded function <optional>
me.game.onLevelLoaded

callback for when the level is fully loaded

flatten boolean <optional>
me.game.mergeGroup

if true, flatten all objects into the given container

static reloadLevel(optionsopt)

reload the current level

Parameters:
Name Type Attributes Description
options Object <optional>

additional optional parameters

Properties
Name Type Attributes Default Description
container me.Container <optional>
me.game.world

container in which to load the specified level

onLoaded function <optional>
me.game.onLevelLoaded

callback for when the level is fully loaded

flatten boolean <optional>
me.game.mergeGroup

if true, flatten all objects into the given container