下面给大家分享一下cocos2dx  char 拼接的内容,主要给大家讲解一下方法内容,打击可以参考学习这些内容,主要内容如下:

for(int i=1;i<5;i++){
        char str[3];
        sprintf(str,"%d",i);

        char totalFilename[30]; 
        strcpy(totalFilename, "game_loading") ;
        const char* suffix = ".png";
        strcat(totalFilename, str);
        strcat(totalFilename, suffix);
        log(totalFilename);
        animation->setDelayPerUnit(0.2f);
        log("%d",sizeof(str[0]));

        char t = 'q';
        log("char %d",sizeof(t));

        float a = 10.30;

        log("t %d",sizeof(&a));
        
        animation->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(totalFilename));
    }

读取XML

Dictionary* dic = Dictionary::createWithContentsOfFile("chineseString.xml");  
String* strchinese   =   (String*)dic->objectForKey("startGame");  



<?xml version="1.0" encoding="utf-8"?>
<plist version="1.0">

  <dict>


    <key>startGame</key>

    <string>从XML里面读取的东东</string>


    <key>japanese</key>

    <string>地方</string>
  </dict>
</plist>
 创建动画Animation

Animation* HelloWorld::getAnimation(const char* stts[],int l,float delay){
    Animation* ac = Animation::create();
    ac->setDelayPerUnit(delay);
    for(int i=0;i<l;i++){
        ac->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(stts[i]));
    }
    return ac;
}


Animation* HelloWorld::getAnimation(const std::string stts[],int l,float delay){
    Animation* ac = Animation::create();
    ac->setDelayPerUnit(delay);
    for(int i=0;i<l;i++){
        ac->addSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(stts[i]));
    }
    return ac;
}
好了,以上就是关于cocos2dx  char 拼接的代码内容。