您好,欢迎访问成都祈钰瑶科技有限公司!

全国咨询热线

18982081108
✕

成都网站建设公司,成都网站UI设计,成都网站安全维护,成都网站内容优化服务

Cocos2d-x中的字符串-创新互联

[html] view plaincopyCocos2d-x中的字符串Cocos2d-x中的字符串

在孝南等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都做网站、网站建设 网站设计制作按需搭建网站,公司网站建设,企业网站建设,成都品牌网站建设,成都全网营销,成都外贸网站建设公司,孝南网站建设费用合理。
  1. <span style="font-weight: normal;"><span style="font-size:14px;"> std::string name = "tony";

  2. std::string name = std::string("tony");</span></span>

[html] view plaincopyCocos2d-x中的字符串Cocos2d-x中的字符串

  1. <span style="font-weight: normal;"><span style="font-size:14px;">const char* cstring = name.c_str();</span></span>

[html] view plaincopyCocos2d-x中的字符串Cocos2d-x中的字符串

  1. <span style="font-weight: normal;"><span style="font-size:14px;">         std::string* name =newstd::string("tony");

  2.          … …

  3.          delete name;</span></span>

[html] view plaincopyCocos2d-x中的字符串Cocos2d-x中的字符串

  1. <span style="font-weight: normal;"><span style="font-size:14px;">      const char* cstring = name->c_str();</span></span>

使用cocos2d::__String

Cocos2d-x中的字符串

<span ><span >static__String * create (const std::string &str)  
static__String * createWithFormat (const char *format,...)</span></span>


  1. <span ><span >__String* name=  __String::create("Hi,Tony");  
    int num=123;  
    __String* ns = __String::createWithFormat("%d",num);  
     </span></span>

  1. <span ><span >__String* name=  __String::create("Hi,Tony");  
    const char *cstring=name->getCString();</span></span>

<span ><span >const char* cstring = "Hi,Tony";  
__String*ns=__String::createWithFormat("%s",cstring);</span></span>


<span ><span >std::string string = "Hi,Tony";     
__String*ns=__String::createWithFormat("%s",string.c_str());</span></span>


<span ><span >int num = 123;  
__String* ns =__String::createWithFormat("%d",num);  
int num2 = ns->intValue();</span></span>


更多内容请关注Cocos2d-x系列图书《Cocos2d-x实战(卷Ⅰ):C++开发》

本书交流讨论网站:http://www.cocoagame.net

欢迎加入cocos2d-x技术讨论群:257760386、327403678

更多精彩内容请关注史上最牛的cocos2d-x课程

《cocos2d-x手机游戏开发实战》直播课程第一期

报名Cocos2d-x直播课程还送关东升老师iOS终身会员。

课程链接:http://edu.51cto.com/pack/view/id-13.html

会员链接:http://edu.51cto.com/member/id-3.html

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。