zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    poj3041——最小点覆盖
    高斯消元
    hdu1704——floyd
    poj2594——最小路径覆盖
    POJ3020 二分图匹配——最小路径覆盖
    我的老博客
    [ZJOI2015]幻想乡战略游戏 动态点分治
    HDU 5737 Differencia set + 主席树
    HDU
    HDU
  • 原文地址:https://www.cnblogs.com/GameCode/p/3768276.html
Copyright © 2011-2022 走看看