Load
This function loads a Leadwerks map (*.map) file.
Syntax
- static bool Load(const std::string& path, int flags=LoadScripts)
- static bool Load(const std::string& path, void hook(Entity* entity, Object* extra), Object* extra=NULL, const int flags=LoadScripts);
- static bool Load(const std::string& path, const std::string& hookname, Object* extra=NULL, const int flags=LoadScripts);
Parameters
- path: the file path to load the scene from.
- hook: pointer to a function that will be called for each loaded entity in the scene.
- hookname: script function name that will be called for each loaded entity in the scene.
- flags: optional bitwise flags that may include any of the following:
- Map: Map::LoadScripts: if included, scripts and flowgraph information contained in the map will be loaded.
Returns
Returns true if the scene was successfully loaded, otherwise false is returned.
Example
#include "App.h"
using namespace Leadwerks;
App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }
bool App::Start()
{
window = Window::Create();
context = Context::Create(window);
world = World::Create();
//Load a map
return Map::Load("Maps/start.map");
}
bool App::Loop()
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
return true;
}