【cocos2d-x】cocos2d-x 2.0.1 使用的一些心得

來源:互聯網
上載者:User

最近有個項目,用上了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);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.