コード例 #1
0
ファイル: main.cpp プロジェクト: pope88/CocInside
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

#ifdef USE_WIN32_CONSOLE
    AllocConsole();
    freopen("CONIN$", "r", stdin);
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
#endif

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setFrameSize(640, 1136);
	eglView->setFrameZoomFactor(0.5f);

    int ret = CCApplication::sharedApplication()->run();

#ifdef USE_WIN32_CONSOLE
    FreeConsole();
#endif

    return ret;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: hanxu101/projectx
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
#ifdef DEBUG_NO_TITLE
    eglView->setViewName(" ");
#else
    eglView->setViewName("ProjectX");
#endif

    // Simply swap width and height for Win32. For other platform, see: http://www.cocos2d-x.org/boards/6/topics/14072
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    eglView->setFrameSize(1536, 2048);
#else
    eglView->setFrameSize(2048, 1536);
#endif

    // The resolution of ipad3 is very large. In general, PC's resolution is smaller than it.
    // So we need to invoke 'setFrameZoomFactor'(only valid on desktop(win32, mac, linux)) to make the window smaller.
    eglView->setFrameZoomFactor(0.4f);
    return CCApplication::sharedApplication()->run();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: guomars/project
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

#ifdef USE_WIN32_CONSOLE
    AllocConsole();
    freopen("CONIN$", "r", stdin);
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
#else
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif

	int nWidth = 1136;
	int nHeight = 640;
	float fFactor = 0.8f;
	int nShowFPS = 0;

	wchar_t szWChar[1024];

	g_SimulateFileName = new char[1024];

	swscanf( lpCmdLine, L"%d %d %f %s", &nWidth, &nHeight, &fFactor, &szWChar);
	int size = wcslen(szWChar);
	sprintf(g_SimulateFileName, "%s", cc_utf16_to_utf8((unsigned short*)szWChar, size, NULL, NULL));

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setFrameSize(nWidth, nHeight);

	eglView->setFrameZoomFactor(fFactor);

	// ÊÇ·ñÏÔʾfps
	CCDirector *pDirector = CCDirector::sharedDirector();
	pDirector->setDisplayStats((nShowFPS == 1));

    int ret = CCApplication::sharedApplication()->run();

#ifdef USE_WIN32_CONSOLE
    FreeConsole();
#endif

    return ret;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: renshengqiang/MiniGame
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setViewName("MiniGame");
    eglView->setFrameSize(SCREEN_WIDTH, SCREEN_HEIGHT);
	eglView->setFrameZoomFactor(0.5);
    return CCApplication::sharedApplication()->run();
}
コード例 #5
0
//-------------------------------------------------------------------------
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

	LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setViewName(A2U("FKImageTool图片格式转译&查看工具").c_str());
    eglView->setFrameSize(1624, 1024);
	eglView->setFrameZoomFactor(0.8f);
    return CCApplication::sharedApplication()->run();
}
コード例 #6
0
ファイル: main.cpp プロジェクト: guoyingbo/ChineseChess
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setViewName("ChineseChess");
    eglView->setFrameSize(1080, 1500);
    // The resolution of ipad3 is very large. In general, PC's resolution is smaller than it.
    // So we need to invoke 'setFrameZoomFactor'(only valid on desktop(win32, mac, linux)) to make the window smaller.
    eglView->setFrameZoomFactor(0.5f);
    return CCApplication::sharedApplication()->run();
}
コード例 #7
0
ファイル: main.cpp プロジェクト: dave5177/share
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setViewName("2048");
    eglView->setFrameSize(1080, 1920);
	 //eglView->setFrameSize(400, 640);
	//eglView->setFrameSize(400, 640);
	eglView->setFrameZoomFactor(0.4f);//ÉèÖÃÆÁÄ»Ëõ·Å±ÈÀý
    return CCApplication::sharedApplication()->run();
}
コード例 #8
0
	MEDUSA_EXPORT_API bool MInitializeApplication( HWND hwnd )
	{

		cocos2d::CCEGLView::SetParentHwnd(hwnd);

		// create the application instance
		AppDelegate app;


		CCEGLView* eglView = CCEGLView::sharedOpenGLView();
		eglView->setViewName("HelloCpp");
		eglView->setFrameSize(960, 640);
		// The resolution of ipad3 is very large. In general, PC's resolution is smaller than it.
		// So we need to invoke 'setFrameZoomFactor'(only valid on desktop(win32, mac, linux)) to make the window smaller.
		eglView->setFrameZoomFactor(1);


		CCApplication::sharedApplication()->run();
		return true;
	}
コード例 #9
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    AllocConsole();   // create console
    SetConsoleTitle(_T("Debug Output"));      // console title
    // redirect STDIN
    {
        FILE*fp;
        errno_t eno=freopen_s(&fp,"CONIN$", "r+t", stdin);
        if(eno!=0) { //failed
            MessageBox(NULL,_T("redirect stdin failed!"),_T("error"),MB_OK|MB_ICONEXCLAMATION);
            exit(0);
        }
    }
    // redirect STDOUT
    {
        FILE*fp;
        errno_t eno=freopen_s(&fp,"CONOUT$", "w+t", stdout);
        if(eno!=0) { //failed
            MessageBox(NULL,_T("redirect stdout failed!"),_T("error"),MB_OK|MB_ICONEXCLAMATION);
            exit(0);
        }

    }

    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
    eglView->setViewName("HelloCpp");
    eglView->setFrameSize(960,640);//(480,320);//(2048, 1536);
    // The resolution of ipad3 is very large. In general, PC's resolution is smaller than it.
    // So we need to invoke 'setFrameZoomFactor'(only valid on desktop(win32, mac, linux)) to make the window smaller.
    eglView->setFrameZoomFactor(0.7f);//(0.4f);
    return CCApplication::sharedApplication()->run();
}
コード例 #10
0
ファイル: main.cpp プロジェクト: wang-yichun/Gravity
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // create the application instance
    AppDelegate app;
    CCEGLView* eglView = CCEGLView::sharedOpenGLView();
	eglView->setViewName("Gravity");
#if PROGRAM_MODE == PROGRAM_MODE_GAME
	eglView->setFrameSize(1280, 800);
#elif PROGRAM_MODE == PROGRAM_MODE_CREATER
	eglView->setFrameSize(1280, 900);
#else
	CCAssert(false, "PROGRAM_MODE unexpect.");
#endif
	eglView->setFrameZoomFactor(.8f);
    return CCApplication::sharedApplication()->run();
}
void HelloWorld::ChangeParticle(float scale, bool isBackgroundMove, int backgroundMoveSpeed, float angle, float angleVar, int destBlendFunc, int srcBlendFunc, float duration, float emissionRate, int emiiterMode,
	GLbyte endColorR,GLbyte endColorG,GLbyte endColorB,GLbyte endColorA,
	GLbyte endColorVarR,GLbyte endColorVarG,GLbyte endColorVarB,GLbyte endColorVarA,
	float endRadius,float endRadiusVar,
	float endSize,float endSizeVar,
	float endSpin,float endSpinVar,
	float gravityX,float gravityY,
	bool isAutoRemoveOnFinish,
	float life,float lifeVar,
	int positionType,
	float positionVarX,float positionVarY,
	float radialAccel,float radialAccelVar,
	float rotatePerSecond,float rotatePerSecondVar,
	float sourcePositionX,float sourcePositionY,
	float speed,float speedVar,
	GLbyte startColorR,GLbyte startColorG,GLbyte startColorB,GLbyte startColorA,
	GLbyte startColorVarR,GLbyte startColorVarG,GLbyte startColorVarB,GLbyte startColorVarA,
	float startRadius,float startRadiusVar,
	float startSize,float startSizeVar,
	float startSpin,float startSpinVar,
	float tangentialAccel,float tangentialAccelVar,
	char* plistPath,char* texturePath,char* textureImageData,
	unsigned int totalParticles
	)
{

	if (texturePath==NULL||strlen(texturePath)==0)
	{
		return;
	}

	//mBackground->setScale(scale);

	CCSize size= CCDirector::sharedDirector()->getWinSize();

	if (totalParticles!=mEmiiter->getTotalParticles())
	{
		mEmiiter->removeFromParentAndCleanup(true);

		mEmiiter=new CCParticleSystemQuad();

		mEmiiter->initWithTotalParticles(totalParticles);
		mEmiiter->setPosition(ccp(size.width/2,size.height/2));

		mEmiiter->setTexture(CCTextureCache::sharedTextureCache()->addImage("fire.png"));

		mBackground->addChild(mEmiiter,1);
	}

	//if (isBackgroundMove!=mIsBackgroundMove)
	//{
		mIsBackgroundMove=isBackgroundMove;


		mBackground->stopAllActions();
		mBackground->setPosition(ccp(size.width/2,size.height/2));

		if (mIsBackgroundMove)
		{
			CCActionInterval* move1 = CCMoveBy::create(1.0 / backgroundMoveSpeed, CCPointMake(100,0) );
			CCActionInterval* move2 = CCMoveBy::create(1.0 / backgroundMoveSpeed, CCPointMake(0,100) );
			CCActionInterval* move3 = CCMoveBy::create(1.0 / backgroundMoveSpeed, CCPointMake(-100,0) );
			CCActionInterval* move4 = CCMoveBy::create(1.0 / backgroundMoveSpeed, CCPointMake(0,-100) );

			CCFiniteTimeAction* seq = CCSequence::create(move1, move2, move3,move4,NULL);
			mBackground->runAction( CCRepeatForever::create((CCActionInterval*)seq) );
		}
	//}

	CCTexture2D *tex = NULL;

	if (texturePath!=NULL)
	{
		// set not pop-up message box when load image failed
		bool bNotify = CCFileUtils::sharedFileUtils()->isPopupNotify();
		CCFileUtils::sharedFileUtils()->setPopupNotify(false);


		//tex = CCTextureCache::sharedTextureCache()->addImage(texturePath);
		if (tex==NULL)
		{
			std::string secondPath=plistPath;
			secondPath+="/";
			secondPath+=texturePath;
			tex = CCTextureCache::sharedTextureCache()->addImage(secondPath.c_str());
		}
		
		// reset the value of UIImage notify
		CCFileUtils::sharedFileUtils()->setPopupNotify(bNotify);
	}

	if (tex)
	{
		mEmiiter->setTexture(tex);
	}
	else
	{                        
		
		unsigned char *buffer = NULL;
		unsigned char *deflated = NULL;
		CCImage *image = NULL;

		CCAssert(textureImageData, "");

		int dataLen = strlen(textureImageData);
		if(dataLen != 0)
		{
			// if it fails, try to get it from the base64-gzipped data    
			int decodeLen = base64Decode((unsigned char*)textureImageData, (unsigned int)dataLen, &buffer);
			CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData");


			int deflatedLen = ZipUtils::ccInflateMemory(buffer, decodeLen, &deflated);
			CCAssert( deflated != NULL, "CCParticleSystem: error ungzipping textureImageData");

			// For android, we should retain it in VolatileTexture::addCCImage which invoked in CCTextureCache::sharedTextureCache()->addUIImage()
			image = new CCImage();
			bool isOK = image->initWithImageData(deflated, deflatedLen);
			CCAssert(isOK, "CCParticleSystem: error init image with Data");

			mEmiiter->setTexture(CCTextureCache::sharedTextureCache()->addUIImage(image, texturePath));

			image->release();
		}

		CC_SAFE_DELETE_ARRAY(buffer);
		CC_SAFE_DELETE_ARRAY(deflated);
	}

	mEmiiter->setAngle(angle);
	mEmiiter->setAngleVar(angleVar);


	ccBlendFunc func;
	func.dst=destBlendFunc;
	func.src=srcBlendFunc;
	mEmiiter->setBlendFunc(func);

	mEmiiter->setDuration(duration);
	mEmiiter->setEmissionRate(emissionRate);
	mEmiiter->setEmitterMode(emiiterMode);

	ccColor4F endColor=ccc4FFromccc4B(ccc4(endColorR,endColorG,endColorB,endColorA));
	mEmiiter->setEndColor(endColor);

	ccColor4F endColorVar=ccc4FFromccc4B(ccc4(endColorVarR,endColorVarG,endColorVarB,endColorVarA));
	mEmiiter->setEndColorVar(endColorVar);

	if (emiiterMode==kCCParticleModeGravity )
	{
		mEmiiter->setGravity(ccp(gravityX,gravityY));
		mEmiiter->setSpeed(speed);
		mEmiiter->setSpeedVar(speedVar);

		mEmiiter->setTangentialAccel(tangentialAccel);
		mEmiiter->setTangentialAccelVar(tangentialAccelVar);

		mEmiiter->setRadialAccel(radialAccel);
		mEmiiter->setRadialAccelVar(radialAccelVar);

	}
	else if (emiiterMode==kCCParticleModeRadius)
	{
		mEmiiter->setStartRadius(startRadius);
		mEmiiter->setStartRadiusVar(startRadiusVar);

		mEmiiter->setEndRadius(endRadius);
		mEmiiter->setEndRadiusVar(endRadiusVar);

		mEmiiter->setRotatePerSecond(rotatePerSecond);
		mEmiiter->setRotatePerSecondVar(rotatePerSecondVar);
	}



	mEmiiter->setEndSize(endSize);
	mEmiiter->setEndSizeVar(endSizeVar);

	mEmiiter->setEndSpin(endSpin);
	mEmiiter->setEndSpinVar(endSpinVar);

	mEmiiter->setAutoRemoveOnFinish(isAutoRemoveOnFinish);

	mEmiiter->setLife(life);
	mEmiiter->setLifeVar(lifeVar);
	mEmiiter->setPositionType((tCCPositionType)positionType);
	mEmiiter->setPosVar(ccp(positionVarX,positionVarY));

	mEmiiter->setSourcePosition(ccp(sourcePositionX,sourcePositionY));

	ccColor4F startColor=ccc4FFromccc4B(ccc4(startColorR,startColorG,startColorB,startColorA));
	mEmiiter->setStartColor(startColor);

	ccColor4F startColorVar=ccc4FFromccc4B(ccc4(startColorVarR,startColorVarG,startColorVarB,startColorVarA));
	mEmiiter->setStartColorVar(startColorVar);

	mEmiiter->setStartSize(startSize);
	mEmiiter->setStartSizeVar(startSizeVar);

	
	mEmiiter->setTotalParticles(totalParticles);

	mEmiiter->resetSystem();

	CCEGLView* eglView = CCEGLView::sharedOpenGLView();

	eglView->setFrameZoomFactor(1.f * scale);
}
コード例 #12
0
ファイル: ui.cpp プロジェクト: evamango/quick-MornUI
int UiPlayer::run(void)
{
    const char *QUICK_COCOS2DX_ROOT = getenv("QUICK_COCOS2DX_ROOT");
    SimulatorConfig::sharedDefaults()->setQuickCocos2dxRootPath(QUICK_COCOS2DX_ROOT);

    loadProjectConfig();

    HWND hwndConsole = NULL;
    if (m_project.isShowConsole())
    {
        AllocConsole();
        freopen("CONOUT$", "wt", stdout);
        freopen("CONOUT$", "wt", stderr);

        // disable close console
        hwndConsole = GetConsoleWindow();
        if (hwndConsole != NULL)
        {
            HMENU hMenu = GetSystemMenu(hwndConsole, FALSE);
            if (hMenu != NULL) DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);

            ShowWindow(hwndConsole, SW_SHOW);
            BringWindowToTop(hwndConsole);
        }
    }

    if (m_project.isWriteDebugLogToFile())
    {
        const string debugLogFilePath = m_project.getDebugLogFilePath();
        m_writeDebugLogFile = fopen(debugLogFilePath.c_str(), "w");
        if (!m_writeDebugLogFile)
        {
            CCLOG("Cannot create debug log file %s", debugLogFilePath.c_str());
        }
    }

    do
    {
        m_exit = TRUE;

        // create the application instance
        m_app = new AppDelegate();
        m_app->setProjectConfig(m_project);

        // set environments
        SetCurrentDirectoryA(m_project.getProjectDir().c_str());
        CCFileUtils::sharedFileUtils()->setSearchRootPath(m_project.getProjectDir().c_str());
        CCFileUtils::sharedFileUtils()->setWritablePath(m_project.getWritableRealPath().c_str());

        // create opengl view
        CCEGLView* eglView = CCEGLView::sharedOpenGLView();
        eglView->setMenuResource(MAKEINTRESOURCE(IDC_LUAHOSTWIN32));
        eglView->setWndProc(WindowProc);
        eglView->setFrameSize(m_project.getFrameSize().width, m_project.getFrameSize().height);
        eglView->setFrameZoomFactor(m_project.getFrameScale());

        // make window actived
        m_hwnd = eglView->getHWnd();
        BringWindowToTop(m_hwnd);
        SetWindowTextA(m_hwnd, "ui-player");

        // restore window position
        const CCPoint windowOffset = m_project.getWindowOffset();
        if (windowOffset.x != 0 || windowOffset.y != 0)
        {
            eglView->moveWindow(windowOffset.x, windowOffset.y);
        }

        // set icon
        HICON icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LUAHOSTWIN32));
        SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon);

        if (hwndConsole)
        {
            SendMessage(hwndConsole, WM_SETICON, ICON_BIG, (LPARAM)icon);
        }

        // update menu
        createViewMenu();
        updateMenu();

        // run game
        CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
        const vector<string> arr = m_project.getPackagePathArray();
        for (vector<string>::const_iterator it = arr.begin(); it != arr.end(); ++it)
        {
            stack->addSearchPath(it->c_str());
        }

        m_app->run();

        // cleanup
        CCScriptEngineManager::sharedManager()->removeScriptEngine();
        CCScriptEngineManager::purgeSharedManager();
        CocosDenshion::SimpleAudioEngine::end();

        delete m_app;
        m_app = NULL;
    } while (!m_exit);

    FreeConsole();
    if (m_writeDebugLogFile) fclose(m_writeDebugLogFile);
    return 0;
}
コード例 #13
0
ファイル: LuaHostWin32.cpp プロジェクト: ascetic85/LuaHostQt
int LuaHostWin32::run(void)
{
    loadProjectConfig();

    AllocConsole();
    freopen("CONOUT$", "wt", stdout);
    freopen("CONOUT$", "wt", stderr);

    // disable close console
    HWND hwndConsole = GetConsoleWindow();
    if (hwndConsole != NULL)
    {
        HMENU hMenu = GetSystemMenu(hwndConsole, FALSE);
        if (hMenu != NULL) DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
    }

    do
    {
        m_exit = TRUE;

        if (m_project.isShowConsole())
        {
            ShowWindow(hwndConsole, SW_SHOW);
            BringWindowToTop(hwndConsole);
        }
        else
        {
            ShowWindow(hwndConsole, SW_HIDE);
        }

        // create the application instance
        m_app = new AppDelegate();
        m_app->setStartupScriptFilename(m_project.getScriptFilePath());

        // set environments
        SetCurrentDirectoryA(m_project.getProjectDir().c_str());
        vector<string> searchPaths;
        searchPaths.push_back(m_project.getProjectDir());
        CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths);

        // create opengl view
        CCEGLView* eglView = CCEGLView::sharedOpenGLView();    
        eglView->setMenuResource(MAKEINTRESOURCE(IDC_LUAHOSTWIN32));
        eglView->setWndProc(WindowProc);
        eglView->setFrameSize(m_project.getFrameSize().width, m_project.getFrameSize().height);
        eglView->setFrameZoomFactor(m_project.getFrameScale());

        // make window actived
        m_hwnd = eglView->getHWnd();
        BringWindowToTop(m_hwnd);

        // restore window position
        const CCPoint windowOffset = m_project.getWindowOffset();
        if (windowOffset.x >= 0 || windowOffset.y >= 0)
        {
            eglView->moveWindow(windowOffset.x, windowOffset.y);
        }

        // set icon
        HICON icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LUAHOSTWIN32));
        SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon);
        SendMessage(hwndConsole, WM_SETICON, ICON_BIG, (LPARAM)icon);

        // run game
        CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
        const vector<string> arr = m_project.getPackagePathArray();
        for (vector<string>::const_iterator it = arr.begin(); it != arr.end(); ++it)
        {
            stack->addSearchPath(it->c_str());
        }

        m_app->run();

        // cleanup
        CCScriptEngineManager::sharedManager()->removeScriptEngine();
        CCScriptEngineManager::purgeSharedManager();
        CocosDenshion::SimpleAudioEngine::end();

        delete m_app;
        m_app = NULL;
    } while (!m_exit);

    FreeConsole();
    return 0;
}
コード例 #14
0
//--------------------------------------------------------------------
int CFKCocos2dxAppWrapper::Run()
{
	bool bRet = 0;

	// first ,load project config
	LoadProjectConfig();

	// create consle
	HWND hwndConsole = NULL;
	if (m_tagAppConfig.IsShowConsole())
	{
		AllocConsole();
		freopen("CONOUT$", "wt", stdout);
		freopen("CONOUT$", "wt", stderr);

		// disable close console
		hwndConsole = GetConsoleWindow();
		if (hwndConsole != NULL)
		{
			HMENU hMenu = GetSystemMenu(hwndConsole, FALSE);
			if (hMenu != NULL) DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);

			ShowWindow(hwndConsole, SW_SHOW);
			BringWindowToTop(hwndConsole);
		}
	}

	// create log file
	if (m_tagAppConfig.IsWriteDebugLogToFile())
	{
		const string debugLogFilePath = m_tagAppConfig.GetDebugLogFilePath();
		m_pWriteDebugLogFile = fopen(debugLogFilePath.c_str(), "w");
		if ( m_pWriteDebugLogFile == NULL )
		{
			FKLOG("Cannot create debug log file %s", debugLogFilePath.c_str());
		}
	}

	// MainLoop
	do
	{
		m_bIsExit = TRUE;

		// create app
		m_pApp = new AppDelegate();
		if( m_pApp == NULL )
		{
			bRet = false;
			break;
		}

		// set some environments
		m_pApp->SetProjectConfig( m_tagAppConfig );
		CCFileUtils::sharedFileUtils()->addSearchPath( m_tagAppConfig.GetProjectDir().c_str() );

		// create openGL view
		CCEGLView* eglView = CCEGLView::sharedOpenGLView();
		eglView->setMenuResource(MAKEINTRESOURCE(IDC_LUAHOSTWIN32));
		eglView->setWndProc (WindowProc );
		eglView->setFrameSize( m_tagAppConfig.GetFrameSize().width, m_tagAppConfig.GetFrameSize().height );
		eglView->setFrameZoomFactor( m_tagAppConfig.GetFrameScale() );

		// set window actived
		m_hWnd = eglView->getHWnd();
		BringWindowToTop(m_hWnd);
		SetWindowTextA(m_hWnd, "FKCocos2dxAppWrapper Project");

		// center window position
		eglView->centerWindow();

		// set icon
		HICON icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LUAHOSTWIN32));
		SendMessage( m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon);
		if (hwndConsole)
		{
			SendMessage(hwndConsole, WM_SETICON, ICON_BIG, (LPARAM)icon);
		}

		// set menu
		CreateViewMenu();
		UpdateViewMenu();

		// run games 
		m_pApp->run();

		// clean up
		CocosDenshion::SimpleAudioEngine::end();

		delete m_pApp;
		m_pApp = NULL;

	}while( !m_bIsExit );

	// ready exit
	FreeConsole();
	if( m_pWriteDebugLogFile != NULL )
	{
		fclose(m_pWriteDebugLogFile);
	}

	return bRet;
}