当前位置: 首页>>代码示例>>C++>>正文


C++ CCEGLView::centerWindow方法代码示例

本文整理汇总了C++中CCEGLView::centerWindow方法的典型用法代码示例。如果您正苦于以下问题:C++ CCEGLView::centerWindow方法的具体用法?C++ CCEGLView::centerWindow怎么用?C++ CCEGLView::centerWindow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCEGLView的用法示例。


在下文中一共展示了CCEGLView::centerWindow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

int CCApplication::run()
{
    PVRFrameEnableControlWindow(false);

    // Main message loop:
    MSG msg;
    LARGE_INTEGER nFreq;
    LARGE_INTEGER nLast;
    LARGE_INTEGER nNow;

    QueryPerformanceFrequency(&nFreq);
    QueryPerformanceCounter(&nLast);

    // Initialize instance and cocos2d.
    if (!applicationDidFinishLaunching())
    {
        return 0;
    }

    CCEGLView* pMainWnd = CCEGLView::sharedOpenGLView();
    pMainWnd->centerWindow();
    ShowWindow(pMainWnd->getHWnd(), SW_SHOW);

    while (1)
    {
        if (! PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // Get current time tick.
            QueryPerformanceCounter(&nNow);

            // If it's the time to draw next frame, draw it, else sleep a while.
            if (nNow.QuadPart - nLast.QuadPart > m_nAnimationInterval.QuadPart)
            {
                nLast.QuadPart = nNow.QuadPart;
                CCDirector::sharedDirector()->mainLoop();
            }
            else
            {
                Sleep(0);
            }
            continue;
        }

        if (WM_QUIT == msg.message)
        {
            // Quit message loop.
            break;
        }

        // Deal with windows message.
        if (! m_hAccelTable || ! TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}
开发者ID:1901,项目名称:cocos2d-x,代码行数:59,代码来源:CCApplication.cpp

示例2: GetConsoleWindow

//--------------------------------------------------------------------
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);
	}
//.........这里部分代码省略.........
开发者ID:duzhi5368,项目名称:FKCocos2dxFramework,代码行数:101,代码来源:main.cpp


注:本文中的CCEGLView::centerWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。