| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include "app_delegate.h" | 4 #include "app_delegate.h" |
| 5 | 5 |
| 6 #include "CCLuaEngine.h" | 6 #include "CCLuaEngine.h" |
| 7 #include "frontend.h" | 7 #include "frontend.h" |
| 8 #include "LuaBox2D.h" | 8 #include "LuaBox2D.h" |
| 9 #include "LuaCocos2dExtensions.h" | 9 #include "LuaCocos2dExtensions.h" |
| 10 #include "lua_physics_layer.h" | 10 #include "lua_level_layer.h" |
| 11 | 11 |
| 12 | 12 |
| 13 USING_NS_CC; | 13 USING_NS_CC; |
| 14 | 14 |
| 15 bool AppDelegate::applicationDidFinishLaunching() { | 15 bool AppDelegate::applicationDidFinishLaunching() { |
| 16 CCEGLView* view = CCEGLView::sharedOpenGLView(); | 16 CCEGLView* view = CCEGLView::sharedOpenGLView(); |
| 17 | 17 |
| 18 CCDirector* director = CCDirector::sharedDirector(); | 18 CCDirector* director = CCDirector::sharedDirector(); |
| 19 director->setOpenGLView(view); | 19 director->setOpenGLView(view); |
| 20 | 20 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 33 return false; | 33 return false; |
| 34 | 34 |
| 35 CCScriptEngineManager::sharedManager()->setScriptEngine(engine); | 35 CCScriptEngineManager::sharedManager()->setScriptEngine(engine); |
| 36 | 36 |
| 37 // Add custom lua bindings on top of what cocos2dx provides | 37 // Add custom lua bindings on top of what cocos2dx provides |
| 38 CCLuaStack* stack = engine->getLuaStack(); | 38 CCLuaStack* stack = engine->getLuaStack(); |
| 39 lua_State* lua_state = stack->getLuaState(); | 39 lua_State* lua_state = stack->getLuaState(); |
| 40 assert(lua_state); | 40 assert(lua_state); |
| 41 // add box2D bindings | 41 // add box2D bindings |
| 42 tolua_LuaBox2D_open(lua_state); | 42 tolua_LuaBox2D_open(lua_state); |
| 43 // add PhysicsLayer bindings | 43 // add LevelLayer bindings |
| 44 tolua_physics_layer_open(lua_state); | 44 tolua_level_layer_open(lua_state); |
| 45 // add cocos2dx extensions bindings | 45 // add cocos2dx extensions bindings |
| 46 tolua_extensions_open(lua_state); | 46 tolua_extensions_open(lua_state); |
| 47 | 47 |
| 48 CCFileUtils* utils = CCFileUtils::sharedFileUtils(); | 48 CCFileUtils* utils = CCFileUtils::sharedFileUtils(); |
| 49 std::string path = utils->fullPathForFilename("loader.lua"); | 49 std::string path = utils->fullPathForFilename("loader.lua"); |
| 50 | 50 |
| 51 // add the location of the lua file to the search path | 51 // add the location of the lua file to the search path |
| 52 engine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); | 52 engine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); |
| 53 | 53 |
| 54 // execute loader file | 54 // execute loader file |
| 55 int rtn = engine->executeScriptFile(path.c_str()); | 55 int rtn = engine->executeScriptFile(path.c_str()); |
| 56 assert(!rtn); | 56 assert(!rtn); |
| 57 if (rtn) | 57 if (rtn) |
| 58 return false; | 58 return false; |
| 59 | 59 |
| 60 // Create the initial (autorelease) scene and run with it. | 60 // Create the initial (autorelease) scene and run with it. |
| 61 CCScene* scene = FrontEndScene::create(); | 61 CCScene* scene = FrontEndScene::create(); |
| 62 director->runWithScene(scene); | 62 director->runWithScene(scene); |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| OLD | NEW |