[置顶] 【cocos2d-x】cocos2d-x 2.0.1 使用的一些心得

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

你可能感兴趣的:(百度,application,animation)