Ejemplo n.º 1
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // turn on display FPS
    pDirector->setDisplayStats(false);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

	pEGLView->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, kResolutionExactFit);

	CCFileUtils *fileUtils = CCFileUtils::sharedFileUtils();
	fileUtils->addSearchPath("fonts");
	fileUtils->addSearchPath("images");
	fileUtils->addSearchPath("sounds");

	CCScene* scene = CCScene::create();
	GameScene* layer = GameScene::create();
	scene->addChild(layer);
	pDirector->runWithScene(scene);

    return true;
}
Ejemplo n.º 2
0
void initLuaGlobalVariables(const std::string& entry)
{
	//GLOBAL_ROOT_DIR
	CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
	CCLuaStack* pStack = pEngine->getLuaStack();
	CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils();
	using namespace std;
	string path = pFileUtils->fullPathForFilename(entry.c_str());
	// replace "\" with "/", normalize the path
	int pos = string::npos;
	while ((pos = path.find_first_of("\\")) != string::npos)
	{
		path.replace(pos, 1, "/");
	}

	string script_dir = path.substr(0, path.find_last_of("/"));
	string root_dir = script_dir.substr(0, script_dir.find_last_of("/"));
	CCLOG("RootDir: %s\nScriptDir: %s \n",root_dir.c_str(), script_dir.c_str());

	std::string env = "GLOBAL_ROOT_DIR=\""; env.append(root_dir); env.append("\"");
	pEngine->executeString(env.c_str());

	env = "__LUA_STARTUP_FILE__=\"";env.append(path);env.append("\"");
	pEngine->executeString(env.c_str());

	pStack->addSearchPath(script_dir.c_str());
	pFileUtils->addSearchPath(root_dir.c_str());
	pFileUtils->addSearchPath(script_dir.c_str());

    ScutExt::Init(root_dir+"/");
}