头文件含有如下代码:
std::string mlabel;
int x=0;
LabelTTF* m_label;
INIT里面有如下代码 char *cstring;
std::string name;
__String *ns;
CCDictionary *strings = CCDictionary::createWithContentsOfFile("disanguan.xml");
for (int i = 0; i < 24; ++i)
{
ns = __String::createWithFormat("%d", i + 1);
cstring = ns->getCString();
name = cstring;
mlabel* = ((CCString*)strings->objectForKey(name))->getCString();
}
m_label = LabelTTF::create(mlabel, "Arial", 40);
m_label->setPosition(Vec2(160, 200));
this->addChild(m_label);
接下来是鼠标点击的代码,为什么会报错呢!说不能把TTF转换成const std::string??????
bool HelloWorld::onTouchBegan(Touch *touch, Event *unused_event)
{
Point location = touch->getLocation();
auto spr = (Sprite*)this->getChildByTag(1);
Rect rect = spr->getBoundingBox();
if (rect.containsPoint(location))
{
m_label->setString(us);
}
else
CCLOG("NO!NO!NO!NO!NO!NO!NO!");
return true;
}*