cocos2dx 字符串拼接

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;
}

 

posted @ 2014-06-04 17:07  向恺然  阅读(4610)  评论(0编辑  收藏  举报

我必须说的是:我崇尚开源,但鄙视剽窃。本博客所有引用的图片,文章,和代码,均只作为研究学习使用,不作为商业应用。如果我无意中冒犯了您,请发消息留言,我将立即删除。