Cocos2d-x问题收集

所有代码运行版本均在Cocos-2dx 2.1.3版本中测试通过


  • 报错提示:cannot define a compiler-generated special member function (must be declared in the class first)

  在头文件中添加此方法的声明,C++在使用函数时必须先声明再使用。

  • 如何使用CCLabelTTF显示数字
int Count;
CCString* strScore=CCString::createWithFormat("%d",count);//使用格式转化

CCLabelTTF *labelTargetDestroyed = CCLabelTTF::create("Destroyed:","Artial",12);
		labelTargetDestroyed->setString(strScore->m_sString.c_str());
  • 设置窗口大小、窗口标题
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView->setViewName("PandoRun");  //窗口标题
eglView->setFrameSize(480, 320);   //窗口大小
  •  设置背景图
CCSprite* pSprite = CCSprite::create("back.png");
CC_BREAK_IF(! pSprite);

 // Place the sprite
        pSprite->setAnchorPoint(CCPointZero);
        pSprite->setPosition(CCPointZero);

        // Add the sprite
        this->addChild(pSprite);
原文地址:https://www.cnblogs.com/s1099312273/p/3402304.html