本文整理汇总了C++中CCString::appendWithFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ CCString::appendWithFormat方法的具体用法?C++ CCString::appendWithFormat怎么用?C++ CCString::appendWithFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCString
的用法示例。
在下文中一共展示了CCString::appendWithFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateView
void MapCell::updateView(const char *mapName, const Size &gridScale)
{
int x = ((int)gloabIndex.x < 0 ? 0 : (int)gloabIndex.x);
int y = ((int)gloabIndex.y < 0 ? 0 : (int)gloabIndex.y);
String urlMapName;
urlMapName.initWithFormat("%s%s/", url.c_str(), mapName);
request->setUrl(urlMapName.getCString(), NULL);
// 根据全局索引设置sprite
String miniName;
miniName.initWithFormat("MiniMaps/%s.png", mapName);
Texture2D * texture = TextureCache::getInstance()->addImage(miniName.getCString());
Rect rect(gloabIndex.x * 32, texture->getContentSize().height - (gloabIndex.y + 1)* 32, 32, 32);
int heightGird = texture->getContentSize().height * 8 / 256;
int widthGird = texture->getContentSize().width * 8 / 256;
CCString fileName;
if (x >= 0 && y >= 0 && x <= widthGird - 1 && y <= heightGird - 1)
{
sprite = Sprite::createWithTexture(texture, rect);
this->addChild(sprite);
sprite->setAnchorPoint(ccp(0, 0));
sprite->setScaleX(gridScale.width); // 宽
sprite->setScaleY(gridScale.height);// 高
CCString str;
str.appendWithFormat("LOGING %u %u", y, x);
fileName.appendWithFormat("%u_%u.png", x, y);
int index = x + (heightGird - y - 1) * widthGird;
fileName.initWithFormat("0000%d.png", index);
char buffer[10] = { 0 };
std::string temp = fileName.getCString();
for (int i = 8; i >= 0; i--)
{
buffer[i] = temp.back();
temp.pop_back();
}
LabelTTF * info = LabelTTF::create(buffer, "Arial", 13);
info->setPosition(ccp(128, 128));
this->addChild(info);
// log("load picture %s\n",fileName.getCString());
request->addFile(buffer, new MapCellResourceCallback(this));
request->go();
request->release();
}
else request->release();
}