记录下,方便以后寻找
参考 http://blog.csdn.net/wildfireli/article/details/9054185
http://blog.csdn.net/honghaier/article/details/7887873
http://www.cnblogs.com/xieheng/p/3611588.html
win32,main入口
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // create the application instance AppDelegate app; return Application::getInstance()->run(); }
UNREFERENCED_PARAMETER:作用,不必显示警告
AppDelegate app; //AppDelegate继承private Application继承public ApplicationProtocolApplicationProtocol是一个抽象类,定义了Platform平台一些程序运行状态的函数,applicationDidFinishLaunching,applicationDidEnterBackground,applicationWillEnterForeground帧数,当前语言,当前平台CCApplication:抽象类(没有实现父类所有接口函数),单列模式
Application::getInstance()->run();
//...if(!applicationDidFinishLaunching())->在AppDelegate中实现{
return 0;
}
//...
//主循环
while(!glview->windowShouldClose()) { QueryPerformanceCounter(&nNow); if (nNow.QuadPart - nLast.QuadPart > _animationInterval.QuadPart) { nLast.QuadPart = nNow.QuadPart; director->mainLoop(); glview->pollEvents(); } else { Sleep(0); } }
AppDelegate中实现
bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLView::create("My Game");// director->setOpenGLView(glview); } // turn on display FPS director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); // create a scene. it's an autorelease object auto scene = HelloWorld::createScene(); // run director->runWithScene(scene); return true; }
//todo java
cocos2d-x 程序的结束流程
在弹出最后一个场景,直接调用CCDirector::end();触发游戏清理工作purgeDirector