本文整理汇总了C++中TextureAtlas::GetImageName方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureAtlas::GetImageName方法的具体用法?C++ TextureAtlas::GetImageName怎么用?C++ TextureAtlas::GetImageName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureAtlas
的用法示例。
在下文中一共展示了TextureAtlas::GetImageName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
void Part::Load(FileNode *fileNode)
{
//Entity::Load(fileNode);
fileNode->Read("id", id);
fileNode->Read("name", name);
sprite = NULL;
SetGraphic(NULL);
TextureAtlas *textureAtlas = puppet->GetTextureAtlas();
if (textureAtlas)
{
TextureAtlasEntry *textureAtlasEntry = NULL;
fileNode->Read("atlasEntry", atlasEntry);
if (atlasEntry != "")
{
textureAtlasEntry = textureAtlas->GetEntryByName(atlasEntry);
if (textureAtlasEntry)
{
sprite = new Sprite(textureAtlas->GetImageName());
SetGraphic(sprite);
sprite->textureOffset = textureAtlasEntry->GetTextureOffset();
sprite->textureScale = textureAtlasEntry->GetTextureScale();
printf("textureOffset: (%f, %f) textureScale: (%f, %f)\n", sprite->textureOffset.x, sprite->textureOffset.y, sprite->textureScale.x, sprite->textureScale.y);
sprite->width = textureAtlasEntry->GetWidth();
sprite->height = textureAtlasEntry->GetHeight();
}
}
}
if (sprite == NULL)
{
std::string image;
fileNode->Read("image", image);
sprite = new Sprite(image);
SetGraphic(sprite);
}
if (sprite != NULL)
{
int width=-1, height=-1;
fileNode->Read("width", width);
fileNode->Read("height", height);
if (width != -1)
{
sprite->width = width;
}
if (height != -1)
{
sprite->height = height;
}
fileNode->Read("offset", sprite->position);
}
int layer = 0;
fileNode->Read("layer", layer);
SetLayer(layer);
// if (sprite)
// {
// std::string atlas;
// fileNode->Read("atlas", atlas);
// if (atlas != "")
// {
// int x, y, width, height, maxWidth=-1, maxHeight=-1;
// std::istringstream is(atlas);
// is >> x >> y >> width >> height >> maxWidth >> maxHeight;
//
// if (maxWidth == -1)
// maxWidth = width;
// if (maxHeight == -1)
// maxHeight = height;
//
// sprite->textureOffset = Vector2(x/float(maxWidth), y/float(maxHeight));
// sprite->textureScale = Vector2(width/float(maxWidth), height/float(maxHeight));
//
// sprite->width = width;
// sprite->height = height;
// }
// }
}