+
+void GameLayer::loadSceneLoader()
+{
+ state_.script.import_standard_libraries();
+ moof::log::import(state_.script);
+
+ std::string path = moof::resource::find_file("scenes/loader.lua");
+ if (path.empty())
+ {
+ throw std::runtime_error("cannot find scene loader script");
+ }
+
+ moof::script::status status = state_.script.do_file(path);
+ if (status != moof::script::success)
+ {
+ std::string str;
+ state_.script[-1].get(str);
+ throw std::runtime_error("script error: " + str);
+ }
+
+ state_.script.globals().push_field("scenes");
+ state_.script.top().get(state_.sceneList);
+ if (state_.sceneList.size() == 0)
+ {
+ throw std::runtime_error("no variable `scenes' in script loader.");
+ }
+}
+
+void GameLayer::advanceScene(moof::settings& settings)
+{
+ if (state_.sceneList.size() != 0)
+ {
+ state_.scene = Scene::alloc(state_.sceneList[0]);
+ state_.sceneList.erase(state_.sceneList.begin());
+
+ moof::script::status status = state_.scene->load(settings,
+ state_.script);
+ if (status != moof::script::success)
+ {
+ std::string str;
+ state_.script[-1].get(str);
+ throw std::runtime_error("script error: " + str);
+ }
+
+ moof::script::slot table = state_.script.globals().push_field("Event");
+ if (table.is_table())
+ {
+ state_.script.push("Think");
+ table.push_field("Think");
+ state_.script.registry().set_field();
+ }
+ state_.script.pop();
+ }
+}
+
+
+GameLayer::GameLayer()
+{
+ moof::log_info("about to load sound resource...");
+ music_.sample("sounds/NightFusionIntro.ogg");
+ music_.loop(true);
+ music_.enqueue("sounds/NightFusionLoop.ogg");
+ music_.position(moof::vector3(10.0, 5.0, 0.0));
+
+ mThinkTimer.init(boost::bind(&GameLayer::thinkTimer, this),
+ 0.1, moof::timer::repeat);
+
+ state_.heroine = Heroine::alloc();
+ state_.heroine->animation.startSequence("FlyDiagonallyUp");
+
+ state_.interp.init(0.0, 1.0, 4.0, moof::lerp_scalar::oscillate);
+
+ sceneMesh = moof::resource::load("classic.ac");
+}