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;
    }
  • 相关阅读:
    avalon随笔
    ms-attr-data-real-gold="{{page_data[0].gold}}" 属性付真
    jQuery 快捷操作
    jQuery 属性操作
    jQuery 表单域选中选择器
    jQuery 层次选择器
    jQuery 基本选择器
    jQuery 基本使用
    jQuery 引入多个库文件冲突
    BOM window对象方法
  • 原文地址:https://www.cnblogs.com/GameCode/p/3768276.html
Copyright © 2011-2022 走看看