cocos2d学习(02)——CCApplication类中的run方法分析

cocos2d学习(02)——CCApplication类中的run方法分析,第1张

概述CCApplication类中的run方法分析 1: int CCApplication::run() 2: { 3: PVRFrameEnableControlWindow(false); //windows相关的,不理会 4:  5: // Main message loop: message消息loop循环 6: MSG msg; 7: L CCApplication类中的run方法分析
 1: int CCApplication::run()
 2: {
 3:     PVRFrameEnableControlWindow(false);    //windows相关的,不理会
 4:
 5:     // Main message loop: message消息loop循环
 6:     MSG msg;
 7:     LARGE_INTEGER nFreq;
 8:     LARGE_INTEGER nLast;
 9:     LARGE_INTEGER nNow;
 10:     //WinBase.h中声明的两个函数,不用理会
 11:     queryPerformanceFrequency(&nFreq);
 12:     queryPerformanceCounter(&nLast);
 13:
 14:     //初始化cocos2d应用实例
 15:     // Initialize instance and cocos2d.
 16:     if (!applicationDIDFinishLaunching())
 17:     {
 18:         //applicationDIDFinishLaunching()函数在AppDelegate中实现
 19:         return 0;
 20:     }
 21:     //下面都是和windows窗口显示相关的,暂时不理会
 22:     CCEGLVIEw* pMainWnd = CCEGLVIEw::sharedOpenGLVIEw();
 23:     pMainWnd->centerWindow();
 24:     ShowWindow(pMainWnd->getHWnd(),SW_SHOW);
 25:     //死循环,程序
 26:     while (1)
 27:     {
 28:         if (! PeekMessage(&msg,NulL,PM_REMOVE))
 29:         {
 30:             // Get current time tick.获取当前时间标记
 31:             queryPerformanceCounter(&nNow);
 32:             //获取到的时间是绘制下一个帧的时间,就绘制。否则继续while循环
 33:             // If it's the time to draw next frame,draw it,else sleep a while.
 34:             if (nNow.QuadPart - nLast.QuadPart > m_nAnimationInterval.QuadPart)
 35:             {
 36:                 nLast.QuadPart = nNow.QuadPart;
 37:                 CCDirector::sharedDirector()->mainLoop();
 38:             }
 39:             else
 40:             {
 41:                 Sleep(0);
 42:             }
 43:             continue;
 44:         }
 45:
 46:         if (WM_QUIT == msg.message)
 47:         {
 48:             // Quit message loop.
 49:             break;
 50:         }
 51:
 52:         // Deal with windows message.
 53:         if (! m_hAcceltable || ! TranslateAccelerator(msg.hwnd,m_hAcceltable,&msg))
 54:         {
 55:             TranslateMessage(&msg);
 56:             dispatchMessage(&msg);
 57:         }
 58:     }
 59:
 60:     return (int) msg.wParam;
 61: }
总结

以上是内存溢出为你收集整理的cocos2d学习(02)——CCApplication类中的run方法分析全部内容,希望文章能够帮你解决cocos2d学习(02)——CCApplication类中的run方法分析所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1013003.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存