最近有個項目,用上了cocos2d-x 的最新版本,2.0.1,是用過程中發現了一些問題,這裡記錄一下。
- 通過 CCSprite 載入圖片的時候,發現有些圖片就是一直報錯,記憶體存取違規。
百度了一下,發現是目前的版本的CCImage_Common.h 中載入 8位的png 有問題,會在下一個版本(2.0.2)中修複。
- 以前使用的實現幀動畫的方法不能用,修改了一下才可以。
CCAnimation *redfish_animation = CCAnimation::create();redfish_animation->setDelayPerUnit(0.1f);for(int i = 1; i <12; i++) {sprintf(str, "scene2/cup/%d.png", i);redfish_animation->addSpriteFrameWithFileName(str);}redfish->runAction( CCRepeatForever::create( CCAnimate::create(redfish_animation) ) );
- 改變視窗大小的函數,現在在 main.cpp 中了。
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("Hello World"); eglView.setFrameSize(1024, 768); // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. // eglView.setDesignResolutionSize(480, 320); return CCApplication::sharedApplication().run();}
需要修改eglView.setFrameSize(1024, 768);