CCLablettf读取显示xml文件内容显示中文

时间:2021-08-04 16:31:58
  1. CCDictionary *strings = CCDictionary::createWithContentsOfFile("tips2.xml");
  2. const char *hello = ((CCString*)strings->valueForKey("tp1"))->m_sString.c_str();
  3. CCLabelTTF *labelHello = CCLabelTTF::create(hello, "fonts/Microsoft YaHei.ttf", 40);
  4. labelHello->setPosition(ccp(100, 100));
  5. labelHello->setAnchorPoint(ccp(0.5, 0.5));
  6. //设置居中对齐
  7. labelHello->setHorizontalAlignment(kCCTextAlignmentLeft);
  8. labelHello->setPosition(ccp(267,182));
  9. //设置显示框大小
  10. labelHello->setDimensions(CCSizeMake(500, 200));
  11. labelHello->setColor(ccc3(6, 48, 90));
  12. pReliveBoard->addChild(labelHello, 1);