我从服务器获取json数据 -
if (response->isSucceed()) {
log("Get success");
std::vector<char>* buffer = response->getResponseData();
std::string res;
res.insert(res.begin(), buffer->begin(), buffer->end());
log("res: %s", res.c_str());
rapidjson::Document d;
d.Parse<0>(res.c_str());
if(d.IsObject()){
log("true"); // print the value of obtaining hello
}
F = d["F"].GetString();
W = d["W"].GetString();
T = d["T"].GetString();
Fp = d["Fp"].GetString();
Wp = d["Wp"].GetString();
Tp = d["Tp"].GetString();
} 现在我想使用标签显示“F”的值... F的值是整数。
所以我这样做 -
foodnumber = Label::createWithTTF(F, "fonts/A little sunshine.ttf", 40 );
foodnumber->setColor(Color3B(109,61,23));
foodnumber->setPosition( Vec2(foodtitle->getPositionX() + foodtitle-
>getContentSize().width/4 + origin.x, foodtitle->getPositionY() + origin.y)
);
this->addChild( foodnumber);
它不打印值...
F中的值是数字。
但是当我记录该值时,它会被记录正确,但它不会在应用程序上显示为标签。
谢谢